Sam
Sam

Reputation: 1

How to change the color of all parts of the Menu Strip in C#

Please look carefully at the picture

How can I change the color of the white parts in the image below?

Image1

I used :

ToolStripManager - ProfessionalColorTable - ToolStripProfessionalRenderer

but they weren't useful.

I want my menu to look like the image below.No white parts.

Image2

I used the following method to solve this problem, but it didn't help.

First I created the class "MyProfessionalColors" and inherited from "ProfessionalColorTable".

then I Override all the Properties related to the MenuStrip.

class MyProfessionalColors : ProfessionalColorTable
{
    public override Color MenuStripGradientBegin
    {
        get
        {
            return Color.FromArgb(35, 35, 35);
        }
    }
    public override Color MenuStripGradientEnd
    {
        get
        {
            return Color.FromArgb(35, 35, 35);
        }
    }
    public override Color MenuItemPressedGradientBegin
    {
        get
        {
            return Color.FromArgb(20, 20, 20);
        }
    }
    public override Color MenuItemPressedGradientMiddle
    {
        get
        {
            return Color.FromArgb(20, 20, 20);
        }
    }
    public override Color MenuItemPressedGradientEnd
    {
        get
        {
            return Color.FromArgb(20, 20, 20);
        }
    }
    public override Color MenuBorder
    {
        get
        {
            return Color.FromArgb(20, 20, 20);
        }
    }
    public override Color MenuItemSelected
    {
        get
        {
            return Color.FromArgb(50, 50, 50);
        }
    }
    public override Color MenuItemSelectedGradientBegin
    {
        get
        {
            return Color.FromArgb(50, 50, 50);
        }
    }
    public override Color MenuItemSelectedGradientEnd
    {
        get
        {
            return Color.FromArgb(50, 50, 50);
        }
    }
    public override Color MenuItemBorder
    {
        get
        {
            return Color.FromArgb(35, 35, 35);
        }
    }
}

Then I used it

 ToolStripManager.Renderer = new ToolStripProfessionalRenderer
                        (new MyProfessionalColors());

But part of the control didn't change color.

How can I change that part?

Do I need to create a custom control and use it?

Upvotes: 0

Views: 546

Answers (1)

Omar media
Omar media

Reputation: 1

You can't use ProfessionalColorTable in the renderer. Accept to learn about ToolStripProfessionalRenderer.

Upvotes: -2

Related Questions