Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I dynamically change color in C# to a hex value?

I know how to set a control's BackColor dynamically in C# to a named color with a statement such as Label1.BackColor = Color.LightSteelBlue; ( using System.Drawing; )

But how do I convert a hex value into a System.Color , ie Label1.BackColor = "#B5C7DE

like image 209
Lill Lansey Avatar asked Jun 24 '09 12:06

Lill Lansey


1 Answers

I would use the color translator as so:

var color = ColorTranslator.FromHtml("#FF1133");

Hope this helps.

like image 187
Richard Avatar answered Oct 13 '22 05:10

Richard