How to change the appearance of a MenuStrip [duplicate]

旧城冷巷雨未停 提交于 2019-11-27 21:41:09

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

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!