Prevent ToolStripDropDownButton from being closed as long as no item is clicked
How can I prevent a ToolStripDropDownButton from being closed until a item or the arrow that opens the menu is clicked?
A standart .net Winforms ToolStripDropDownButton holds its menu just as long open as you hover the menu with the mouse...
I thought of catching it in the closing event and then say e.Cancel = false but unfortunately it seems like ToolSt开发者_运维百科ripDropDownButton has no closing event just the ToolStripDropDown
ToolStripDropDownButton
is just a wrapper for ToolStripDropDown
. You can just use its DropDown property to access ToolStripDropDown like this:
ToolStripDropDownButton buttonStates = new ToolStripDropDownButton();
buttonStates.DropDown.Closing += new ToolStripDropDownClosingEventHandler(buttonStatesDropDown_Closing);
private void buttonStatesDropDown_Closing(object sender, ToolStripDropDownClosingEventArgs e)
{
e.Cancel = true;
}
精彩评论