Change the highlight color of WinForms buttons

I found this page that describes how to change the rendering for MenuStrip and its elements.

I want to use this, but the problem is that the color of the backlight when you hover over the button does not match it.

Is there a way to change the backlight color from blue to yellow? I tried using the MouseHover and MouseLeave events, but for some reason they are very slow and they change the button to a solid color that looks bad but leaves a border on the edge of the button that doesn't change.

In the designer:

this.ButtonName.MouseHover += new System.EventHandler(button_mousehover);

And then in the code:

private void button_mousehover(object sender, EventArgs e)
{
    Button btn = sender as Button;
    btn.BackColor = Color.Yellow;
}

Is there anything as simple as the link I wrote above to change the highlight color from blue to something else?

Here is the code to change the rendering of the menu bar:

private void myForm Load(object sender, EventArgs e)
{
    myMenuStrip.Renderer = new MenuRenderer();
{

private class MenuRenderer : ToolStripProfessionalRenderer
{
    public MenuRenderer() : base(new MyColors()) { }
}

private class MyColors : ProfessionalColorTable
{
    public override Color MenuItemSelectedGradientBegin
    {
        get { return Color.Orange; }
    }
    public override Color MenuItemSelectedGradientEnd
    {
        get { return Color.Yellow; }
    }
    public override Color MenuItemPressedGradientBegin
    {
        get{ return Color.Yellow; }
    }
    public override Color MenuItemPressedGradientEnd
    {
        get { return Color.Orange; }
    }
    public override Color MenuItemSelected
    {
        get { return Color.Gold; }
    }
}

, - , - , .

, , ( /) .

+4
2

Button Renderer.

, MouseHover :

this.someButtonName.MouseHover += (s,e) => 
{
   this.someButtonName.BackColor = Color.Yellow;
};

, reset , .

+1

:
" /FlatStyle " "".
" /FlatAppearance/MouseOverBackColor " .

0

Source: https://habr.com/ru/post/1570343/


All Articles