Link to home
Start Free TrialLog in
Avatar of tora111
tora111

asked on

How to loop through each element ToolStrip includes all menuitems

I can get each item on the ToolStrip by the following codes.

        Dim tObj As ToolStripItem
        For Each tObj In ToolStrip.Items
               debug.pring tObj.name
        Next

However it didn't include the menu item inside the "ToolStripSplitButton" or "ToolStripDropDownButton"

So how to loop through each element includes all menuitem ?
Avatar of Fahad Mukhtar
Fahad Mukhtar
Flag of Pakistan image

       For Each obj As Object In ToolStrip1.Items
            If TypeOf (obj) Is ToolStripButton Then
                MessageBox.Show("ToolStripButton")
                CType(obj, ToolStripButton).Visible = False 'chnage/use whatever property you like

            ElseIf TypeOf (obj) Is ToolStripDropDownButton Then
                MessageBox.Show("ToolStripDropDownButton")
                CType(obj, ToolStripDropDownButton).Visible = False 'chnage/use whatever property you like
            End If
        Next
Avatar of tora111
tora111

ASKER

Desp,

Your code still cannot show the menuitem within the "ToolStripDropDownButton" !!!
ASKER CERTIFIED SOLUTION
Avatar of Fahad Mukhtar
Fahad Mukhtar
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial