How to iterate thru a toolstrip collection

D

Dean Slindee

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
 
R

rowe_newsgroups

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top