Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ContextMenuStrip on NotifyIcon 1

Status
Not open for further replies.

wiler

Programmer
May 6, 2007
2
DE
Hi,
I'm using vb.net(2005) and I want to run programs when I click on an Item in a ContextMenuStrip (CMS).

The Items for the CMS are added from a listbox. How can I find out which Item is clicked on? I have tried this with:

-----
Private Sub CMSIcon_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CMSIcon.MouseClick

Call Shell("path", AppWinStyle.NormalFocus)

End Sub
-----
What has the path to be?

Thanks a lot
 
Hi,

I'm not sure to understand what you're really trying to achieve but here what you could do:

Code:
    Private Sub ContextMenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) [b]Handles ContextMenuStrip1.ItemClicked[/b]
        MessageBox.Show([b]e.ClickedItem[/b].Name, "Name of clicked item", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

Hope it helps
 
Yes, that's what I was looking for!
I have changed "e.ClickedItem.Name" with "e.ClickedItem.Text" and it works.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top