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

Popup menu ContextMenuStrip

Status
Not open for further replies.

aspvbnetnerd

Programmer
May 16, 2006
278
SE
Is it possible create a popup menu like with windows programming (vb.net) with a contextmenustrip?
When the user right clicks on a listbox show the popupmenu?

Something like this.
Create the menu.
Code:
CmsStatusMenu.Items.Clear()
CmsStatusMenu.Font = New System.Drawing.Font("Arial", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
CmsStatusMenu.Items.Add(FormLogIn.htbLang.Item(10022).ToString, Nothing, New System.EventHandler(AddressOf CmsStatusMenuOpenBox))   'Öppna
CmsStatusMenu.Items.Add(FormLogIn.htbLang.Item(10023).ToString, Nothing, New System.EventHandler(AddressOf CmsStatusMenuCloseBox))  'Stäng

Show the popup menu.
Code:
Private Sub lstOpened_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstOpened.MouseDown

If e.Button = Windows.Forms.MouseButtons.Right AndAlso lstOpened.SelectedItems.Count >= 1 Then
                lstOpened.ContextMenuStrip = CmsStatusMenu
Else
                lstOpened.ContextMenuStrip = Nothing
End If

End Sub

And then a listbox
 
It is possible, but by doing so you remove the user's standard browser context menu, something which they may not thank you for. If you still want to do it, try asking in the javascript forum as you'll need a client-side solution.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top