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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Context Menu not working

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
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
 
From what I can tell, the issue is with your select case. You set the case statement to lower case, and yet each individual case is not lower case.

Select Case mi.Text.ToLower()
Case "&NSLookup" (should this not be "&nslookup"?)

Have you followed the code execution to determe what is or is not being executed?

If at first you don't succeed, then sky diving wasn't meant for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top