Index of clicked ToolStripMenuItem

How to know the index of clicked ToolStripMenuItem
tetooAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Stephen MandersonConnect With a Mentor Software EngineerCommented:
There isn't an index property on the toolstrip item click, however you could include the index in the tag property of each of the tool strip items and call the following to find what the tag (Containing the index)

I would wait to see what other suggestions people have though.

Regards
Steve


    Private Sub ToolStrip1_ItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ToolStrip1.ItemClicked
        MsgBox(e.ClickedItem.Tag)
    End Sub

Open in new window

0
 
Bruce_1975Connect With a Mentor Commented:
It's a litte bit tricky to get it.
I tried it with ToolStripButton, but should work also for other ToolStripItem derevates.

Regards,
Bruce
private void MyCallBack(object sender, EventArgs e)
{
    ToolStripItem item = sender as ToolStripItem;
    int index = item.Owner.Items.IndexOf(item)
}

Open in new window

0
All Courses

From novice to tech pro — start learning today.