mare.zim
mare.zim

Reputation: 219

Change of the background color in minimized MenuStrip

I have a Windows Forms application with a MenuStrip. BackColor is blue, but when the window is resized (in the image you see only left corner of the menu) and I want to display other hidden items, the background is not blue.

How can I change the background color?

enter image description here

Upvotes: 0

Views: 114

Answers (1)

napi15
napi15

Reputation: 2402

Check out this : ToolStripProfessionalRenderer

public class MyToolStripRenderer : ToolStripProfessionalRenderer
{
    /* override styling/drawing here */
}

MenuStrip strip = new MenuStrip();

strip.Renderer = new MyToolStripRenderer();

//this will set RenderMode to "Custom"

Exemple :

public  class TestColorTable : ProfessionalColorTable
{
    public override Color MenuItemSelected
    {
        get { return Color.Red; }
    }

    public override Color MenuBorder  //added for changing the menu border
    {
        get { return Color.Green; }
    }

You would use it like this:

private void Form1_Load(object sender, EventArgs e)
{
    menuStrip1.Renderer = new ToolStripProfessionalRenderer(new TestColorTable());
}

Upvotes: 1

Related Questions