Question

I need to iterate with a loop through all the items in a RibbonPageGroup. I try to set the Visibility property from all Ribbon Items to '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
Was it helpful?

Solution

There are no bar items within the RibbonPageGroup. You can iterate bar item links via the RibbonPageGroup.ItemLinks property.

Please refer to Accessing Bar Items and Links article for more information.

OTHER TIPS

You could do this using LINQ:

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

I had the same problem. Sorted it with this piece of coding. Works perfectly:

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top