Avoid Toolstripmenu close on items or Dropdownitem selected

882 views Asked by At

I have Toolstrip menu items. It is having two level of menu items. How to avoid close functionality of Toolstrip menu item when clicks on level 2 menu item and retains the previous one.

Example, enter image description here

1

There are 1 answers

1
Capn Jack On

You're going to want to specify closing behaviour for the drop down to not close on item click. Try this:

toolStripDropDownButton1.DropDown.Closing += toolStripDropDownButton1_Closing;

private void toolStripDropDownButton1_Closing(object sender, ToolStripDropDownClosingEventArgs e)
{
    if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
    {
        e.Cancel = true;
    }
}