I have the below code that shows the popup of the context menu, but when the menu item is selected nothing happens. what am I not doing?
Code:
Private Sub Lstservers_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstServers.MouseUp
Dim ctx As New ContextMenu
Dim i1 As New MenuItem("&NSLookup")
Dim i2 As New MenuItem("&Telnet")
Dim i3 As New MenuItem("&Remove")
AddHandler i1.Click, AddressOf ContextMenuHandler
AddHandler i2.Click, AddressOf ContextMenuHandler
AddHandler i3.Click, AddressOf ContextMenuHandler
ctx.MenuItems.Add(i1)
ctx.MenuItems.Add(i2)
ctx.MenuItems.Add(i3)
lstServers.ContextMenu = ctx
End Sub
Private Sub ContextMenuHandler(ByVal Sender As Object, ByVal e As EventArgs)
Dim mi As MenuItem = DirectCast(sender, MenuItem)
Select Case mi.Text.ToLower()
Case "&NSLookup"
sname = lstServers.Items.ToString
TabControl1.SelectedTab = NetworkTools
TabControl1.Focus()
MsgBox("nslookup")
'Your add functionality here
Case "&Telnet"
MsgBox("case2")
'Your edit functionality here
Case "&Remove"
MsgBox("case3")
'Your delete functionality here
End Select
End Sub