C# – Custom Context Menu

cnetwinforms

I'd like to create a custom context menu. The idea is to create a panel with a textBox a button and a list of labels and be able to show it on right click and make it behave exactly like a contextMenu. I can probably use a form without borders but I was thinking there might be a class I can derive from that would help me handle the positionnig of the context menu and the shading. Any ideas?
Thank you

Edit: An example to clear a few ideas: Say you have a label on your form, when you right click on it (or even left click) a menu appears. This menu is NOT the classic context menu but rather a custom panel with controls that I created personnaly. An example is search box ont top with a list of items. As you enter letters the list is trimmed to the matching items and when an item is clicked the context menu disappears and the value selected is wrtitten in the label we first clicked on.

Best Answer

You can use the method described here:

http://www.codeproject.com/Articles/22780/Super-Context-Menu-Strip

Since it uses ContextMenuStrip you can set its position:

contextMenuStrip1.Show(Cursor.Position);

and shadow effect:

http://msdn.microsoft.com/en-us/library/system.windows.controls.contextmenu.hasdropshadow.aspx

Related Topic