[英]ToolStripMenuItem not closing when a child ToolStripMenuItem is Clicked in a C# WinForm
Is there a way to have a ToolStripMenuItem not closing when I click a child control (in its DropDrowItems Collection)? 当我单击子控件(在其DropDrowItems集合中)时,有没有办法使ToolStripMenuItem不关闭?
In my case, I have some ToolStripMenuItems that work as a check box. 在我的例子中,我有一些ToolStripMenuItems作为一个复选框。 Actually, I implemented a radio behavior in some ToolStripMenuItems using their Check property.
实际上,我使用Check属性在一些ToolStripMenuItems中实现了一个无线电行为。 But I don't want the menu closing when I click any of them, because they aren't an action, they represent just options in the menu item.
但是当我点击它们中的任何一个时我不想关闭菜单,因为它们不是动作,它们只代表菜单项中的选项。
Is that possible? 那可能吗?
this.menuItem.DropDown.Closing += new ToolStripDropDownClosingEventHandler(DropDown_Closing);
void DropDown_Closing(object sender, ToolStripDropDownClosingEventArgs e)
{
if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
{
e.Cancel = true;
((ToolStripDropDownMenu) sender).Invalidate();
}
}
Just for your information: 仅供参考:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.