Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to loop through each element ToolStrip includes all menuitems

Posted on 2006-06-12
3
Medium Priority
?
2,216 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:Fahad Mukhtar
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:
Fahad Mukhtar earned 750 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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