OammieR
OammieR

Reputation: 2870

ForeColor with codes color

I have created dynamically HyperLink. And I want to change the color by adding a color code.

HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
hpl.ForeColor = "#5BB1E6";

//Cannot implicitly convert type 'string' to 'System.Drawing.Color

But I can't.

How to add codes color to ForeColor ?

Is it possible?

Upvotes: 6

Views: 10256

Answers (3)

Krishanu Dey
Krishanu Dey

Reputation: 6406

Use

hpl.ForeColor =System.Drawing.ColorTranslator.FromHtml("#5BB1E6");

Upvotes: 0

koolprasad2003
koolprasad2003

Reputation: 307

you can use following code, it may help you

HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
//use this
hpl.ForeColor = System.Drawing.Color.FromName("#5BB1E6")

hope it helps

Upvotes: 0

Rab
Rab

Reputation: 35582

Use the following code

HyperLink hpl = new HyperLink();
hpl.Text = "SomeText";
hpl.ForeColor = System.Drawing.ColorTranslator.FromHtml("#5BB1E6");

Upvotes: 11

Related Questions