0

Just attempting to make my UI less Windows-looking. I was testing a few of the item's events and tried controlling the background using the BackColor property, but to no avail. Is there any convenient way to alter the default colors?

Thanks in advance.

The menu item's back color turns light-blue when hovered by the cursor.

When an item is clicked, its back color turns light-gray, making the item's text hardly visible.

Nat
  • 1
  • 1
  • The colors are typically determined by the selected Windows theme... I don't have a direct answer to your question off-hand unfortunately - it has been over 5 years since I last developed a WinForms app. – Brian Driscoll Oct 09 '15 at 20:58
  • 1
    You will have to override the renderer. My example: [Disable toolstripmenuitem highlight?](http://stackoverflow.com/questions/26508662/disable-toolstripmenuitem-highlight/26509155#26509155) Plenty other examples on this site. – LarsTech Oct 09 '15 at 20:58
  • Unsolicited advice: if you want it to look less like a windows forms app, use WPF. That said, this might help? http://stackoverflow.com/questions/25425948/c-sharp-winforms-toolstripmenuitem-change-background – Nikki9696 Oct 09 '15 at 21:13

1 Answers1

1

Simply create your ow color table from the ProfessionalColorTable.

private class MyColours : ProfessionalColorTable
{
    public override Color MenuItemSelected
    {
        get { return Color.Blue; }
    }
    public override Color MenuItemSelectedGradientBegin
    {
        get { return Color.DarkCyan; }
    }
    public override Color MenuItemSelectedGradientEnd
    {
        get { return Color.Cyan; }
    }

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

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

Add another class to render these colors as follows.

private class NewColourRenderer : ToolStripProfessionalRenderer
{
    public NewColourRenderer(): base(new MyColours()){}            
}

Then use your new renderer in the form load event:

menuStrip1.Renderer = new NewColourRenderer();
noufalcep
  • 3,446
  • 15
  • 33
  • 51
Darren
  • 51
  • 3