Visual Studio C # Windows Forms ... button color change?

I have a form (see screenshot):

default form look

As you can see, this is a fairly simple form with a save button. I programmed it so that if any text field has changed, the SAVE button will change color, so its obvious that I have not pressed, saved, and not forgotten. Unfortunately, simply changing the BackColor buttons to red is not enough, because its UGLY is like a sin.

ugly backcolor unsaved

What can I do to change the button color to red, but not so ugly. As you can see, "BackColor" does not change the entire button, but only the inside. The border still remains the same old-fashioned transparent gray color.

+5
source share
5 answers

LinearGradientBrush , .

button1.ForeColor = Color.White;

Bitmap bmp = new Bitmap(button1.Width, button1.Height);
using (Graphics g = Graphics.FromImage(bmp)) {
  Rectangle r = new Rectangle(0, 0, bmp.Width, bmp.Height);
  using (LinearGradientBrush br = new LinearGradientBrush(
                                      r,
                                      Color.Red,
                                      Color.DarkRed,
                                      LinearGradientMode.Vertical)) {
      g.FillRectangle(br, r);
    }
  }

BackgroundImage :

  button1.BackgroundImage = bmp;

:

enter image description here

. .

+12

Icon (, ) , , .

+2

"FlatStyle". . " ", . :

,

0

WinForms, WPF. , . ( )

: OP . , C & P'd WPF, fyi

Edit²: WPF, 30% XAML. , .

-1
source

All Articles