Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a right click menu to an item

I have been searching for a while for a simple right-click menu for a single item. For example if I right-click on a picture I want a little menu to come up with my own labels: Add, Remove etc. If anyone could help I would be most greatful.

Thanks for looking.

Here is the completed code:

    ContextMenu cm = new ContextMenu();                  cm.MenuItems.Add("Item 1", new EventHandler(Removepicture_Click));                  cm.MenuItems.Add("Item 2", new EventHandler(Addpicture_Click));                   pictureBox1.ContextMenu = cm;  
like image 205
Marshal Avatar asked Mar 22 '12 14:03

Marshal


1 Answers

Add a contextmenu to your form and then assign it in the control's properties under ContextMenuStrip. Hope this helps :).

Hope this helps:

ContextMenu cm = new ContextMenu(); cm.MenuItems.Add("Item 1"); cm.MenuItems.Add("Item 2");  pictureBox1.ContextMenu = cm; 
like image 64
Yuki Kutsuya Avatar answered Oct 24 '22 10:10

Yuki Kutsuya