How to change button color using RGB or Hexadecimal code?

Asked

Viewed 2,572 times

0

I have a Winforms application and would like to use colors that are not in the presets of the object Color, how could I do that ? By way of example:

How the code is found:

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)");

2 answers

3

2


using .FromArgb()tbm 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);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.