开发者

Right style menu by right clicking

开发者 https://www.devze.com 2023-02-21 19:36 出处:网络
Goal: Have a right click menu with a right style Problem: How should i retrieve this style when I\'m right clicking:

Goal:

Have a right click menu with a right style

Problem:

How should i retrieve this style when I'm right clicking:

Right style menu by right clicking

and not this style:

Right style menu by right clicking

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消