Ive built some simple code to add a label onto a form and attach a ContextMenu to it, however I cannot seem to find a way to discover what was pressed (ie New, Edit or delete). Ive looked through the values of sender, and although I can find what label was clicked, I cant seem to find what item was clicked.
What Ive got soo far:-
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim newLabel As New Label
newLabel.Size = New Size(32, 16)
newLabel.Location = New Point(10, 10)
newLabel.Text = "Hello"
Dim newContextMenu As New ContextMenuStrip
AddHandler newContextMenu.Click, AddressOf menuClicked
newLabel.ContextMenuStrip = newContextMenu
Private Sub menuClicked(ByVal sender As Object, ByVal e As EventArgs)
'Get what label has been clicked
Me.Text = CType(sender, ContextMenuStrip).SourceControl.Text
'Get which menu item was clicked
Ive done a search on google, but cannot find any relevant information to this, any ideas?