Solved

Index of clicked ToolStripMenuItem

Posted on 2008-06-18
4
2,339 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 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