I have created a contextmenu (cnt_hys) and am adding items to it as program runs based on the user input in textbox1. when the user clicks button1 the contextmenu shows up and when the user clicks an item on the contextmenu strip i want to get the text of the clicked item.
I am using this code but it always returns returns the first item even if the user clicks the last item
Dim s As String = CType(sender, ContextMenuStrip).GetItemAt( _
CType(sender, ContextMenuStrip).DisplayRectangle.X, _
CType(sender, ContextMenuStrip).DisplayRectangle.Y).Text.Trim()
i got the while browsing the web i dont remember where i got it
I have also tried the following
Dim s as string = ""
Dim myItem As ToolStripMenuItem = CType(sender, ToolStripMenuItem)
Dim cms As ContextMenuStrip = CType(myItem.Owner, ContextMenuStrip)
s = cms.SourceControl.Name
so anyone knows how i can bypass this problem?
thnx in advnc