I have a form (see screenshot):
As you can see, its a pretty basic form, with a save button. I have programmed it so that if any of the text fields get changed, the "SAVE" button changes color so that its obvious that I haven't clicked save and don't forget to. Unfortunately, simply changing the BackColor of the button to red isn't enough, because its UGLY as sin.
What can I do to change the color of the button to red, but not as ugly. As you can see, the "BackColor" doesn't change the entire button, just the inner piece. The border is still the same old fashioned transparent grey.
Visual Studio Code is a lightweight, cross-platform development environment that runs on Windows, Mac, and Linux systems. The Microsoft C/C++ for Visual Studio Code extension supports IntelliSense, debugging, code formatting, auto-completion. Visual Studio for Mac doesn't support Microsoft C++, but does support .
Download & Install the C/C++ Extension We need to click on the extension button that displays a sidebar for downloading and installing the C/C++ extension in the visual studio code. In the sidebar, type C Extension. In this image, click on the Install button to install the C/C++ extension.
A fully-featured, extensible, free IDE for creating modern applications for Android, iOS, Windows, as well as web applications and cloud services.
A little bit of a LinearGradientBrush
can go a long way to soften the harshness of a pure red button.
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);
}
}
then you can just assign the image to the button's BackgroundImage
property:
button1.BackgroundImage = bmp;
Result:
Note: Assigning a background image will lose the mouse hover coloring of the button.
Another solution would be to add an Icon (e.g. exclamation mark) to the button instead to inform the user that the changes haven't been saved yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With