Is it possible to get the index of an item in a dropdown menu?
+1
A:
private void item_Click(object sender, EventArgs e)
{
ToolStripMenuItem item = sender as ToolStripMenuItem;
if (item != null)
{
int index = (item.OwnerItem as ToolStripMenuItem).DropDownItems.IndexOf(item);
}
}
devnull
2010-09-27 14:31:16
MenuStrip is not what I will call dropdown menu...
Petar Minchev
2010-09-27 14:33:02
@Petar - looking at previously asked questions shows what OP means...
devnull
2010-09-27 14:34:42
@devnull OK, that makes sense. Thanks:)
Petar Minchev
2010-09-27 14:35:26
@Petar - one of the menu items has items add'ed to the DropDownItems list. And i want to find the index of the dropdown item i click on.
Bildsoe
2010-09-28 07:35:33
@Bildsoe - i've updated my answer
devnull
2010-09-28 07:58:16
@devnull - works perfectly! Thanks a bunch! I've accepted the answer.
Bildsoe
2010-09-28 08:01:08