Reputation: 455
I have a button control. I'd like to change it's text's font color into a custom color that I want which is #33CCFF, programmatically.
My current code is
Button1.ForeColor = Color.#33CCFF;
I have also tried
Button1.ForeColor = #33CCFF;
Both didnt work..
What's the correct way of doing this?
Upvotes: 3
Views: 9372
Reputation: 5325
You could use:
Button1.ForeColor = (Color)ColorConverter.ConvertFromString("#33CCFF");
For reference: ColorConverter on MSDN
Alternatively you can use ColorTranslator
:
Button1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#33CCFF");
Upvotes: 6
Reputation: 5265
Button1.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFF00");
where you can use an RGB hexadecimal code.
Upvotes: 0
Reputation: 37710
Button1.ForeColor = Color.FromArgb(0x0033CCFF);
Reference : Color.FromArgb Method
Upvotes: 0