Solved

Index of clicked ToolStripMenuItem

Posted on 2008-06-18
4
2,318 Views
Last Modified: 2011-10-03
How to know the index of clicked ToolStripMenuItem
0
Comment
Question by:tetoo
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

862 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now