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.
Asked
Active
Viewed 794 times
1
-
do you have `ToolStripMenuItem1.DropDown.AutoClose = true?` – Capn Jack Aug 28 '17 at 15:13
-
Yes, if I set AutoClose to false still level 2 items is closing – user1645200 Aug 28 '17 at 17:31
-
Am I correct in saying you want to be able to click an item in menu2 and have it select the item (put a checkmark beside it) but not close it? So after selecting say `SubItem 5.1`, menu1 and menu2 remain open? – Capn Jack Aug 28 '17 at 18:04
-
Yes, Capn Jack you are correct, after selecting SubItem 5.1, menu 1(level 1 menu items) and menu 2 (level 2 subItem) should not close and it should remain open only – user1645200 Aug 28 '17 at 18:35
-
Did you see my answer? – Capn Jack Aug 28 '17 at 21:02
1 Answers
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