开发者

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜