The example below returns all of the menu items in a ButtonMenus collection. To try the example, draw a Toolbar control on a form, and paste the code into the Declarations section. Run the project and click the button menus.
Private Sub Toolbar1_ButtonDropDown(ByVal Button As ComctlLib.Button)
' Hide a ButtonMenu based on the index of the Button.
Select Case Button.Index
Case 1
Button.ButtonMenus(1).Visible = False
Case 2
Button.ButtonMenus(2).Visible = False
Case 3
Button.ButtonMenus(3).Visible = False
End Select
End Sub
Private Sub Form_Load()
Dim btn As Button
Dim i As Integer
Dim j As Integer
' Add three buttons to the Toolbar. For each button, add three
' menu items to the ButtonMenus collection.
For i = 1 To 3
Set btn = Toolbar1.Buttons.Add(, , "button " & i, tbrDropdown)
For j = 1 To 3
btn.ButtonMenus.Add , , "button " & i & " menuitem " & j
Next j
Next i
End Sub