Solved

How to loop through each element ToolStrip includes all menuitems

Posted on 2006-06-12
3
2,063 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

695 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