1

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

user1645200
  • 135
  • 2
  • 13

1 Answers1

0

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;
    }
}
Capn Jack
  • 1,201
  • 11
  • 28
  • e.cancel = true is to avoid closing the toolstripmenu item for first level, still if I click on level two menu items (sub menu items), sub menu items are closing and level 1 menu items are remain open. – user1645200 Aug 29 '17 at 01:13