如何在RibbonPageGroup中迭代DevExpress项?

时间:2013-05-13 08:23:57

标签: vb.net visual-studio devexpress ribbon ribbon-control

我需要循环遍历RibbonPageGroup中的所有项目。我尝试将所有功能区项目的Visibility属性设置为'true / always'

    For Each rp As RibbonPage In ribbonControl.Pages
        rp.Visible = True
            For Each pg As RibbonPageGroup In rp.Groups
                    pg.Visible = True
                  For Each btn As DevExpress.XtraBars.BarButtonItem In pg.??????
                      btn.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
                Next
          Next
    Next

3 个答案:

答案 0 :(得分:2)

RibbonPageGroup中没有bar items。您可以通过bar item links属性迭代RibbonPageGroup.ItemLinks

有关详细信息,请参阅Accessing Bar Items and Links文章。

答案 1 :(得分:1)

您可以使用LINQ执行此操作:

For Each bbi As var In RbpVersion.ItemLinks.Cast(Of BarItemLink)().[Select](Function(x) x.Item)
  Console.WriteLine(bbi.Caption)
Next

答案 2 :(得分:0)

我遇到了同样的问题。用这段编码对它进行排序。完美运作:

For Each pagegroup As DevExpress.XtraBars.Ribbon.RibbonPage In rbnSafety.Pages
    For Each group As DevExpress.XtraBars.Ribbon.RibbonPageGroup In pagegroup.Groups
        For Each button As DevExpress.XtraBars.BarButtonItem In group.Ribbon.Items.OfType(Of DevExpress.XtraBars.BarButtonItem)()
        If button.Name <> "rbtnExit" Then
           button.Enabled = False
        End If
        Next
        For Each button As DevExpress.XtraBars.BarSubItem In group.Ribbon.Items.OfType(Of DevExpress.XtraBars.BarSubItem)()
            button.Enabled = False
        Next
     Next
 Next