As in most cases the overall goal could help (and which event are you
handling ?)
My first thought would be first to have the event handled by the specific
event handler tied to this control.
If you need something more generic, my personal preference is to use the
name or just test the object (If sender Is MyObject etc...) rather than the
index.
If you really need the index you'll find an IndexOf method on almost if not
all collections (get at the owner and use the IndexOf method on the
collection that contains these elements to get the index).
--
Patrice
"Academia" <ac************@a-znet.coma écrit dans le message de news:
%2****************@TK2MSFTNGP04.phx.gbl...
>I use to do this:
Dim index As Integer = CType(sender, MenuItem).Index
but ToolStripMenuItems do not have an Index property so I can set the Tag
or MergeIndex property of those items and use that.
But that is error prone since changes in the menu require that those
values be kept synchronized.
Even though there is no Index property I have the feeling that the
collection might have the equivalent.
Is there a way of getting the index of the item in the collection?
Thanks