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

Please help with contextmenu

Status
Not open for further replies.

iannuzzelli

Programmer
Jan 4, 2003
36
US
I have a textbox that when right clicked shows a context menu of values.

Very simple. I need the textbox.text populated with the value.

I can not figure out how to determine what item was selected in the contextmenu. What event is used to determine when a menuitem is selected?

Thanks for any help.
 
Hi - well, the menu items in the context menu are objects in their own right. If you know them all at design time, then you can do something like this

Private Sub ContextClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItem1.Click, MenuItem2.Click, MenuItem3.Click
Dim mnu As MenuItem = CType(sender, MenuItem)
TextBox1.Text = mnu.Text
End Sub


If you are adding to the context menu's items at run time, then you can still take the approach above, but you need to add a handler to the procedure every time you add a menu item.

Finally, why not just use a combo box?

Reply if you need any more help Mark [openup]
 
Thanks for the response.

I just thought the Contextmenu was cool.

I did switch to a combo box but it makes the application look so 1998, Old VB.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top