Question

Let me start from a simple example to reproduce my problem:

  1. Create WinForms project.
  2. Drop a ToolStrip on it.
  3. Make a ToolstripDropdownButton in it (with no children).
  4. Add a click event-handler to the button, with something like this:

    MessageBox.Show("text", "Caption");
    

    (the point is to make the main form loose it's focus).

To make the problem more obvious, let's make a few unnecessary additions:

  1. Set RenderMode of our ToolStip to ManagerRenderMode.
  2. Set it's Autosize to false and make it a lil bigger.

And that's should be enough to reproduce it. Run the app and click the Button. You'll get the popup. Close the popup and voila ... the button now looks like someone is holding it pressed.

Any ideas on how to reset it to it's default state?

I've tried to call Buttons ResetBackColor, Refresh ... also as ToolStrips. Doesn't seem to work. Maybe I'm missing something?

Was it helpful?

Solution

The MessageBox or a modal form will interfere with that. The drop down is expecting children menu items.

Sample work around:

private void toolStripDropDownButton1_Click(object sender, EventArgs e) {
  this.BeginInvoke(new Action(() => MessageBox.Show("Help")));
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top