Recoloring MenuStrip

1k views Asked by At

I have a MenuStrip and I want to change it's color. So far, I have this code:

public class TestColorTable : ProfessionalColorTable
{
    public override Color MenuItemSelected
    {
        get{ return Color.LightGray; } // Don't mind the colors...
    }

    public override Color MenuItemBorder
    {
        get { return Color.LightGray; }
    }

    public override Color MenuItemSelectedGradientBegin
    {
        get { return Color.LightGray; }
    }

    public override Color MenuItemSelectedGradientEnd
    {
        get { return Color.LightGray; }
    }

    public override Color MenuItemPressedGradientBegin
    {
        get { return Color.DimGray; }
    }

    public override Color MenuItemPressedGradientEnd
    {
        get { return Color.DimGray; }
    }

    public override Color MenuBorder
    {
        get { return Color.LightGray; }
    }
}

With this code, as well as the designer, I managed to change the color of almost every element of my MenuStrip. Almost.

Here are the results:

enter image description here

As you can see, there are two issues: 1) The two separators and 2) That thin white border around the submenus.

Any ideas on how to change the color of those two parts of my MenuStrip?

1

There are 1 answers

2
IronGeek On BEST ANSWER
  1. For the separator color try overriding the SeparatorDark and or SeparatorLight property of the ProfessionalColorTable class.

  2. As for the thin white border around the submenus..., well, its actually not a border. It's the ToolStripDropDown (the submenu) background itself. Try overriding the ToolStripDropDownBackground property of the ProfessionalColorTable class to change its color.

Example:

public class TestColorTable : ProfessionalColorTable
{
  ...
  public override Color SeparatorDark
  {
    get { return Color.DimGray; }
  }

  public override Color ToolStripDropDownBackground
  {
    get { return Color.DimGray; }
  }
  ...
}