Creating a color from a string

L

Lee

Hi,

I have saved a Color to a text file using Color.toString(). How do I load
it in again? I have tried;-

Color myColor = Color.FromName(strColor);

but it fails, I have also noticed that the color is sometimes saved with a
name e.g. [Wheat] and sometimes like;-

Color [A=255, R=128, G=255, B=128]

thanks in advance
 
M

Mohammad Shalabi

you can use the ColorConverter class here is an example:
ColorConverter d = new ColorConverter();

Color c1 = Color.Red;

Color r = (Color)d.ConvertFromString(c1.Name);

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top