如果单击打开菜单的项目或箭头,我怎样才能阻止ToolStripDropDownButton关闭?
一个标准的.net Winforms ToolStripDropDownButton保持其菜单与你用鼠标悬停菜单时一样长...
我想在关闭事件中捕获它,然后说e.Cancel = false但不幸的是,似乎ToolStripDropDownButton没有关闭事件只是ToolStripDropDown
答案 0 :(得分:4)
ToolStripDropDownButton
只是ToolStripDropDown
的包装器。你可以使用它的DropDown属性来访问ToolStripDropDown,如下所示:
ToolStripDropDownButton buttonStates = new ToolStripDropDownButton();
buttonStates.DropDown.Closing += new ToolStripDropDownClosingEventHandler(buttonStatesDropDown_Closing);
private void buttonStatesDropDown_Closing(object sender, ToolStripDropDownClosingEventArgs e)
{
e.Cancel = true;
}