How to change button color using RGB or HEX code?

I have a WinForms application and would like to use colors that are not found in the Color object presets, how could I do that ? As an example:

How the code is located:

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)");
Author: Maniero, 2018-04-08

2 answers

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);
 2
Author: Paulo Ricardo, 2018-04-08 22:22:45

Has several ways to do this, one of them is using the FromArgb from Color:

Color.FromArgb(128, 3, 186)

Or

Color.FromArgb(0x80, 0x03, 0xBA)
 3
Author: Maniero, 2018-04-08 22:06:05