C# 帮助为 MenuStrip 添加单选按钮/选项按钮
我是 C# 语言的初学者,所以我需要天才们对这个方案的一些帮助:我需要为菜单条添加一个单选按钮。我已将 CheckOnClick
属性更改为 true
,但我需要一个用于单选按钮选择的选项。您可以从 Windows
计算器菜单栏查看它(单击“查看”)。 如何通过 MenuStrip
属性访问它?
I'm a beginner in C# language, so I need some help from the geniuses with this scheme: I need to add a radio button for a menu strip. I've already changed the, CheckOnClick
property to true
, but I need an option for radio button selection. You can see it from the Windows
calculator menu bar (click View).
How can I get to it via the MenuStrip
property?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是一篇近乎古老的帖子,但我认为值得一提的是,尽管没有对 RadioButton MenueItem 的本机支持,但很容易哄骗他们的复选框以这种方式表现。首先将每个 MenueItem 的
CheckOnClick
属性设置为FALSE
。然后将相同的MouseDown
事件处理程序应用于每个项目:您可以使用
Click
事件代替,但我更喜欢MouseDown
因为它提供了一些可视化用户所检查的项目已更改,同时保持Click
事件打开,以便在需要时对各个项目进行编码。I know this is a near-ancient post, but I thought it worth mentioning that although there's no native support for a RadioButton MenueItem, it's easy enough to coax their checkboxes into behaving that way. Start by setting the
CheckOnClick
property of each MenueItem toFALSE
. Then apply the sameMouseDown
event handler to each item:You could use the
Click
event instead, but I preferMouseDown
because it provides some visualization to the user that the checked item has changed while leaving theClick
event open for coding the individual items if needed.如果导航到
msdn.microsoft.com/en-us/library/ms404318。 aspx
你会看到它是如何完成的;)!
If you navigate to
msdn.microsoft.com/en-us/library/ms404318.aspx
you will see how it's done ;)!