上下文菜单标题 [英] Context menu heading

查看:156
本文介绍了上下文菜单标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为上下文菜单添加标题.
标题不可点击,背景为灰色,并带有粗体.
我尝试通过搜索和使用ownerdraw和drawitem进行尝试,但未成功.
当menuitem的ownerdraw设置为true且使用drawitem绘制上下文菜单时,不会绘制menuitem.

我想要这样

标题(带有灰色背景的粗体,不可单击)
MenuItem1
MenuItem2
MenuItem3

谁能帮忙.

谢谢

I want to add a heading for the context menu.
The heading to be not clickable, with gray back ground with bold text.
I tried by searching and using ownerdraw and drawitem but not succeeded.
when ownerdraw of menuitem set to true and drawitem is used for drawing the contextmenu is not drawing the menuitem.

I want like this

Heading (in bold with gray background and not clickable)
MenuItem1
MenuItem2
MenuItem3

Can anyone please help.

Thanks

推荐答案

我认为您不能在设计器中做到这一点,但我确实遇到了一种以编程方式实现的方法:

http://stackoverflow.com/questions/4595116/c-sharp-context-menu [ ^ ]

本文中的相关代码(再次,不是我的,而是本文中的,因此这是Hans Passant的引用):

I don''t think you can do it in the designer but I did come across a way to do it programmatically:

http://stackoverflow.com/questions/4595116/c-sharp-context-menu[^]

The relevant code from this article (again,not mine but from this article so this is a quote from Hans Passant):

contextMenuStrip1.Items.Insert(0, new ToolStripLabel("Please select an option"));
contextMenuStrip1.Items.Insert(1, new ToolStripSeparator());


这篇关于上下文菜单标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆