How to change button color using RGB or Hexadecimal code?

0

I have a WinForms application and would like to use colors that are not in the default settings of the Color object, how could I do that? For example:

How the code is:

this.btnLogout.BackColor = System.Drawing.Color.Red;

Example of how I would like to set the color:

//this.btnLogout.BackColor = this.btnLogout.setBackColor("#8003ba" ou "rgb(128, 3, 186)");
    
asked by anonymous 08.04.2018 / 23:43

2 answers

2

Using .FromArgb() tbm it is possible to control the Alpha channel that accepts a int from 0 to 255.

//--> ARGB o Alfa vai 0 à 255
button2.BackColor = Color.FromArgb(100, 250, 0, 100);
    
09.04.2018 / 00:09
3

There are several ways you can do this, one of which is using the FromArgb of Color :

Color.FromArgb(128, 3, 186)

Or

Color.FromArgb(0x80, 0x03, 0xBA)
    
09.04.2018 / 00:06