单击 winforms 时不要关闭 ToolStripMenu [英] Do not close ToolStripMenu on clicking in winforms
本文介绍了单击 winforms 时不要关闭 ToolStripMenu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个 c# winform 项目,在用户单击其项目后,主工具条菜单不必隐藏,我该怎么做?
I work on a c# winform project that the main toolstripmenu have not to be hide after user clicks on its item, how can I do that?
推荐答案
设置父菜单项的 AutoClose 属性以防止菜单条关闭.
Set the AutoClose property of the parent menu item to prevent the menu strip from closing.
演示:
ToolStripMenuItem file = new ToolStripMenuItem("File");
file.DropDown.AutoClose = false;
file.DropDownItems.Add("New");
file.DropDownItems.Add("Open");
file.DropDownItems.Add("Exit");
MenuStrip ms = new MenuStrip();
ms.Items.Add(file);
this.Controls.Add(ms);
现在您有责任自己关闭菜单:
Now the responsibility is on you to close the menu yourself:
file.DropDown.Close();
这篇关于单击 winforms 时不要关闭 ToolStripMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文