After doing a little more evaluation, it seems that MOST of the SystemColors
colors have this problem, whereas all of the "plain" Colors do NOT have this
problem.
Here is an example program to see what i mean. Can anyone help me figure out
what i'm doing wrong?
KnownColor t = new KnownColor();
foreach (KnownColor kc in System.Enum.GetValues(t.GetType()))
{
ColorConverter cc = new ColorConverter();
Color c = Color.FromName(kc.ToString());
string s = c.ToArgb().ToString();
bool b = System.Drawing.SystemColors.Control.IsNamedColor;
Color clr = (System.Drawing.Color)(cc.ConvertFromString(s));
bool b2 = clr.IsNamedColor;
System.Diagnostics.Trace.WriteLine(c.ToString() + ": " + (b ==
b2).ToString());
}
Tim
"Tim Mulholland" <Mu***************@alumni.virginia.edu> wrote in message
news:e6*************@TK2MSFTNGP10.phx.gbl...
I am having a problem where a color i select, and convert to a string for
storage in an XML file is not being converted back properly. The following
is a small example that illustrates the problem.The color seems to show up
properly, but it has lost its IsNamedColor property. Is it possible to get
this back or is there any different way i should be doing any of this?
string s = System.Drawing.SystemColors.Control.ToArgb().ToStr ing();
bool b = System.Drawing.SystemColors.Control.IsNamedColor; //Returns true
ColorConverter c = new ColorConverter();
Color clr = (System.Drawing.Color)(c.ConvertFromString(s));
bool b2 = clr.IsNamedColor; //Returns false
Thanks in advance,
Tim