Set Windows Forms background color to hex value
2 answers
The ColorTranslator.FromHtml method converts the HTML color representation to a GDI + Color structure.
- Create a string representation of the HTML color.
- Convert htmlColor to GDI + Color structure.
- Assign this color to your window shape background.
code
string hexColor = "#626262";
Color myColor = System.Drawing.ColorTranslator.FromHtml(hexColor);
form1.BackColor = myColor;
+4
source to share