473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to iterate thru a toolstrip collection

I have a toolStripDropDownButton with child toolStripDropDownMenuItems. I
would like to iterate thru the toolStripDropDownMenuItems and look at the
menuitems and discard the separators. Problem is, these objects cannot be
cast to a Control, at least that's the error message displayed.

How can I determine whether the current item is a menuitem or a separator if
syntax prevents me from doing a GetType to determine what item's type is?

Thanks in advance,
Dean S
Aug 21 '07 #1
1 2871
On Aug 21, 1:42 pm, "Dean Slindee" <slin...@charter.netwrote:
I have a toolStripDropDownButton with child toolStripDropDownMenuItems. I
would like to iterate thru the toolStripDropDownMenuItems and look at the
menuitems and discard the separators. Problem is, these objects cannot be
cast to a Control, at least that's the error message displayed.

How can I determine whether the current item is a menuitem or a separator if
syntax prevents me from doing a GetType to determine what item's type is?

Thanks in advance,
Dean S
I believe you can use typeof - something like:

If TypeOf(item) is ToolStripMenuItem Then
....
End If

Thanks,

Seth Rowe

Aug 21 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Simon | last post by:
I've got a webform and many controls on it. I would like to iterate thru the control collection to get all the textboxes control to let me change the text property. Here is my code...for unknown...
2
by: JDavies | last post by:
Hi All I am dynamically Creating DropDownList boxes for a Survey form. These DropdownLists are added to Table Cells programatically. I tried to loop thru the controls on the form but it doesnt...
2
by: James Doran | last post by:
Hello, I'd like to iterate through each Page of my ASP.NET project from within a Custom web control and access the Page.Controls collection. I've tried using Reflection on the web project...
1
by: Dan Sikorsky | last post by:
How do you recursively iterate thru each collection on each form on a web page and find each web control? -- Thank you kindly, Dan Sikorsky BAB, BScE, MSC
7
by: Rich | last post by:
Hello, I have a form with 5 textboxes named txt0, txt1, txt2, txt3, tx4. In VB6 I could iterate through these with For i = 0 to 4 debug.print Me.controls("txt" & i).Name Next
2
by: osmarjunior | last post by:
In VS2005 there is the class ToolStrip. If I open the CollectionEditor to edit the items of the tool bar, I can choose from a Label, Button, TextBox, ComboBox... I wanna create my own user...
3
by: SemSem | last post by:
i make a tool strip iwant to make ToggleButton as all buttons are push buttons . How i can change this buttons from push to toggle. Thanx at all -------------------------------...
0
by: Martijn Mulder | last post by:
The ToolStrip on top of my form is to small. I want to increase its height. Simply setting the Height-property doesn't change the height, though. So I tried to place the ToolStrip in a...
2
by: daveL | last post by:
Hi I have a Toolstrip on a Window with 5 buttons i want to send this to a application static fucnction to enable / disable the buttons based on User rights When i send Window.controls to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.