views:

75

answers:

1

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
MenuStrip is not what I will call dropdown menu...
Petar Minchev
@Petar - looking at previously asked questions shows what OP means...
devnull
@devnull OK, that makes sense. Thanks:)
Petar Minchev
@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
@Bildsoe - i've updated my answer
devnull
@devnull - works perfectly! Thanks a bunch! I've accepted the answer.
Bildsoe