Goal:
Have a right click menu with a right styleProblem:
How should i retrieve this style when I'm right clicking:and not this style:
I'm using the componen开发者_StackOverflow社区t ContextMenuStrip to display menu by right clicking.
Instead of using ContextMenuStrip, you have to use ContextMenu. This is from MSDN:
Although ContextMenuStrip replaces and adds functionality to the ContextMenu control of previous versions, ContextMenu is retained for both backward compatibility and future use if you choose.
I've tested it with a primitive example and it does work as you want. Please note, that using ContextMenu you lose some designer functionality and you have to manually set some properties in your code file.
In my example I changed ContextMenuStrip to ContextMenu type, all ToolStripItem objects to MenuItem, bound the menu to form's ContextMenu property and removed all size settings (ContextMenu does not use any).
精彩评论