本文介绍了如何遍历窗体内的所有ribboncontrol barbuttunitems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想循环通过我的win表单应用程序来设置我的安全角色。 i有aribboncontrol1,它有六个barbuttunItems。(barbuttunSave,barButtunEdit,barButtunDelete,barButtunNew,barButtunPrint,barButtunExit) i只想使barbuttunSave和barButtunPrint处于活动状态(启用= true) ,具体取决于用户权限。 我尝试过: DataTable Contract_Det = new DataTable(); Contract_Det.Columns.Add( Pri_Name); Contract_Det.Columns.Add(SalemanName); foreach(ribbonControl.Items中的BarButtonItem项目) { if(item is BarButtonItem) { DataRow row = Contract_Det.NewRow(); row [0] = item.Name; row [1] = item.Caption; Contract_Det.Rows.Add(row); } } Dgv_Invoice.DataSource = Contract_Det;i want to loop through my win form Application to set my security roles on it.i have aribboncontrol1 which has six barbuttunItems .(barbuttunSave,barButtunEdit,barButtunDelete,barButtunNew,barButtunPrint,barButtunExit)i want to make only barbuttunSave and barButtunPrint active(enabled=true)depending on the user Privileges.What I have tried:DataTable Contract_Det = new DataTable(); Contract_Det.Columns.Add("Pri_Name"); Contract_Det.Columns.Add("SalemanName"); foreach (BarButtonItem item in ribbonControl.Items) { if (item is BarButtonItem) { DataRow row = Contract_Det.NewRow(); row[0] = item.Name; row[1] = item.Caption; Contract_Det.Rows.Add(row); } } Dgv_Invoice.DataSource = Contract_Det;推荐答案foreach (var item in ribbonControl.Items) { if (item is BarButtonItem) { BarButtonItem bbi = item as BarButtonItem; bbi.isEnabled = ( button id bool exp ); }} 这篇关于如何遍历窗体内的所有ribboncontrol barbuttunitems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-15 05:56