Adam Neal
Adam Neal

Reputation: 2177

Keep a ToolStripDropDownButton dropped down for multiple selections

I have a ToolStripDropDownButton that has multiple children and I'm using them as checkboxes (CheckOnClick=True) so you can check multiple child items.

My question is: how do I keep the parent item "dropped down" so it doesn't close up every time you click a child item?

Upvotes: 2

Views: 781

Answers (2)

user2481095
user2481095

Reputation: 2106

What you want to do is prevent the closing of the drop down in the case that an item was clicked:

dropDownButton.DropDown.Closing += DropDown_Closing;

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

Upvotes: 0

Adam Neal
Adam Neal

Reputation: 2177

So simple I overlooked it - in the click event handler, just call ShowDropDown() on the parent.

Upvotes: 2

Related Questions