Solved

Index of clicked ToolStripMenuItem

Posted on 2008-06-18
4
2,406 Views
Last Modified: 2011-10-03
How to know the index of clicked ToolStripMenuItem
0
Comment
Question by:tetoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 19

Accepted Solution

by:
Stephen Manderson earned 150 total points
ID: 21817984
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
 
LVL 6

Assisted Solution

by:Bruce_1975
Bruce_1975 earned 150 total points
ID: 21822862
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question