How to iterate thru a toolstrip collection

  • Thread starter Thread starter Dean Slindee
  • Start date Start date
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
 
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
 
Back
Top