how do i convert a string to a color.


heres an example of where i need to convert the string "mycolor"

string mycolor = "Blue";
Graphics graphics = paint_pnl.CreateGraphics();
graphics.FillEllipse(new SolidBrush(Color.mycolor), e.X, e.Y, 4, 4);
graphics.Dispose();

Try changing line 3 to

graphics.FillEllipse(new SolidBrush(Color.FromName(mycolor)), e.X, e.Y, 4, 4);

If the color name isn't valid, you get black.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.