Solved

How to loop through each element ToolStrip includes all menuitems

Posted on 2006-06-12
3
1,997 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.net and sql server 4 54
vb.net 1 month apart 11 39
How do you pull mopre then 1000 records using VB.NET Directory Services namespace 2 41
Vb.net threads keep increasing 2 50
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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