Solved

How to loop through each element ToolStrip includes all menuitems

Posted on 2006-06-12
3
1,846 Views
Last Modified: 2010-05-18
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 ?
0
Comment
Question by:tora111
  • 2
3 Comments
 
LVL 19

Expert Comment

by:Desp
ID: 16883709
       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
0
 

Author Comment

by:tora111
ID: 16883907
Desp,

Your code still cannot show the menuitem within the "ToolStripDropDownButton" !!!
0
 
LVL 19

Accepted Solution

by:
Desp earned 250 total points
ID: 16883939
       Dim ddButton As New ToolStripDropDownButton
        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")
                ddButton = CType(obj, ToolStripDropDownButton)

                For Each dditems As ToolStripItem In ddButton.DropDownItems
                    'Put your code
                Next
            End If
        Next
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now