0

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?

Sam
  • 1
  • 4
  • Please show some code to clarify your problem. –  Apr 19 '20 at 21:44
  • Did you see the first picture? I didn't write any code because I don't know where to start. If you look at the first picture, you will understand my questions – Sam Apr 19 '20 at 21:47
  • 1
    Unfortunately, this isn't how Stack Overflow works. Questions you haven't tried to find an answer for (show your work!) are not allowed. –  Apr 19 '20 at 21:52
  • Of course, I tried to find the answer. But none of the ways I went answered me. I rewrote the classes I said and none of them helped. How can I write something that I have no idea about? – Sam Apr 19 '20 at 22:02
  • This indicates that you already wrote code. Show it to us. It doesn't matter if it doesn't work. If you show your code, we can at least figure out the problem together. Learning from a mistake in your own code is better than getting a complete solution immediately. –  Apr 19 '20 at 22:10
  • Your answer was logical. I will do what you said – Sam Apr 19 '20 at 22:15
  • I added the code I wrote – Sam Apr 19 '20 at 23:04
  • I cannot recall correctly which method, but you have to override one of the rendering methods of the renderer class if you want to further customize the look and feel, https://github.com/dockpanelsuite/dockpanelsuite/blob/Release_3.0.6/WinFormsUI/Docking/VisualStudioToolStripRenderer.cs – Lex Li Apr 19 '20 at 23:34
  • [Remove ToolStripMenuItem left border](https://stackoverflow.com/a/37367209/3110834). – Reza Aghaei Apr 20 '20 at 02:41
  • [Change the border color of Winforms menu dropdown list](https://stackoverflow.com/q/32307778/3110834). – Reza Aghaei Apr 20 '20 at 02:42
  • Thank you for your guidance. The solution Reza Aghaei helped. – Sam Apr 20 '20 at 10:39

1 Answers1

-1

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

zx485
  • 28,498
  • 28
  • 50
  • 59
  • **you cant use ProfessionalColorTable in renderer** ? Says who? Did you read your own link? Where do you think the renderer gets the colors to render the different parts? Please read the link you provided carefully. – dr.null Jun 19 '23 at 18:22