Stuart
Stuart

Reputation: 12215

Best way of dynamically setting color of control at runtime

I currently load controls at run time, and want to set the color, but not a named color. I was thinking I need to create a color object , set the color of this then assign it, any direction? Thanks

Upvotes: 1

Views: 3443

Answers (1)

Canavar
Canavar

Reputation: 48088

You can use Color.FromName() method to set colors :

txt.ForeColor = System.Drawing.Color.FromName("#00B300");
txt.ForeColor = System.Drawing.Color.FromName("red");

Upvotes: 1

Related Questions