I need to convert a string which has the name of a color (e.g. "Red") to an object of System.Windows.Media.Color.
I am using the following code:
using System.ComponentModel;
TypeConverter tc = new TypeConverter();
Color bgColor = (Color)(tc.ConvertFrom((li["Background_x0020_Color"].ToString())));
The code builds successfully, but throws a runtime exception : "ConvertFrom not implemented in base TypeConverter."
Any help is greatly appreciated. Thanks!
Try this
http://jyothsnag.blogspot.in/2011/04/convert-string-to-color-object-in.html