Mol73n
Mol73n

Reputation: 23

How can I change the selected MenuStrip button color on click?

I have MenuStrip with 2 buttons. When I click one of them the color changes to white.

Not clicked

Not Clicked

Clicked

Clicked

How can I change the color of the clicked button when selected?

Upvotes: 1

Views: 1012

Answers (1)

LarsTech
LarsTech

Reputation: 81610

You need to supply your own Renderer:

public class RendererEx : ToolStripProfessionalRenderer {

  protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) {
    //base.OnRenderMenuItemBackground(e);
    e.Item.BackColor = Color.Black;
  }
}

Then apply it in the form's constructor:

menuStrip1.Renderer = new RendererEx();

Upvotes: 1

Related Questions