Question

I add a MenuStrip in my app and is add on ManagerRenderMode at Render Mode. The problem is with the appearance, look offal. Look at those two photos, I want to change that white border of submenus in transparent, that blue rectangule that look offal on gray for the menu and for the submenu in dark gray (and his border that is a dark blue) and the border white of menu when is selected. How I can do this ?

BackColor is: 36; 36; 36 and ForeColor is LightGray.

enter image description here

enter image description here

I managed to change the blue rectangle, the white rectangle when the option is selected, the blue rectangle when I select an option of submenus, but I don't know how to change the white border, please help..

Here is the code so far...

        Color culoare = Color.FromArgb(20, 20, 20);
        Color culoare1 = Color.FromArgb(36, 36, 36);

        public override Color MenuItemSelected
        {
            get { return culoare; }
        }

        public override Color MenuItemBorder
        {
            get { return culoare; }
        }

        public override Color MenuItemSelectedGradientBegin
        { 
            get { return culoare; } 
        }

        public override Color MenuItemSelectedGradientEnd
        { 
            get { return culoare; } 
        }

        public override Color MenuItemPressedGradientBegin
        { 
            get { return culoare; }
        }

        public override Color MenuItemPressedGradientEnd
        {
            get { return culoare; }
        }

        public override Color MenuBorder
        {
            get { return culoare; }
        }
Was it helpful?

Solution

You can do this by creating your own ColorTable, and overriding the properties you wish to change the colour of:

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());
}

OTHER TIPS

Your approach is incorrect. You do not style menus and toolstrips using forecolor/backcolor.

Take a look at ToolStripProfessionalRenderer

Example on how to use this

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

MenuStrip strip = new MenuStrip();

strip.Renderer = new MyToolStripRenderer();

//this will set RenderMode to "Custom"

consider using this example on CodeProject as some research.

Better still, VBForums have loads of them, already implemented (in the usual Luna, Office, Windows, Visual Studio styles!)

http://www.vbforums.com/showthread.php?596563-100-Customizable-MenuStrip-ToolStrip-StatusStrip-including-common-presets

If you simply want to chaneg the colors...use Pondidum's answer! It involves less work!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top