I knew it would be something simple like that :)
That's what i get for believing what i read on the web ;)
Thanks!
Tim
"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:uB4okbamDHA.2200@TK2MSFTNGP12.phx.gbl...[color=blue]
> Tim,
>
> You are storing the wrong string values. If you want to convert a[/color]
color[color=blue]
> to a string, you should not be using the RGB value. If the value is an[/color]
RGB[color=blue]
> value, then it doesn't know that it is a named color value. In order to[/color]
get[color=blue]
> the correct color, you should use the ConvertToString method on the
> ColorConverter class to get the string representation of the color. Once
> you have this, if you pass it to the ConvertFromString method, then you[/color]
will[color=blue]
> find that IsNamedColor returns true.
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> -
mvp@spam.guard.caspershouse.com
>
> "Tim Mulholland" <Mulholland.NoSpam@alumni.virginia.edu> wrote in message
> news:%23Iav$BamDHA.1728@TK2MSFTNGP09.phx.gbl...[color=green]
> > After doing a little more evaluation, it seems that MOST of the[/color]
> SystemColors[color=green]
> > colors have this problem, whereas all of the "plain" Colors do NOT have[/color]
> this[color=green]
> > problem.
> > Here is an example program to see what i mean. Can anyone help me figure[/color]
> out[color=green]
> > 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" <Mulholland.NoSpam@alumni.virginia.edu> wrote in[/color][/color]
message[color=blue][color=green]
> > news:e6q$z4ZmDHA.708@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > I am having a problem where a color i select, and convert to a string[/color][/color]
> for[color=green][color=darkred]
> > > storage in an XML file is not being converted back properly. The[/color][/color]
> following[color=green][color=darkred]
> > > is a small example that illustrates the problem.The color seems to[/color][/color][/color]
show[color=blue]
> up[color=green][color=darkred]
> > > properly, but it has lost its IsNamedColor property. Is it possible to[/color][/color]
> get[color=green][color=darkred]
> > > 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[/color][/color]
> true[color=green][color=darkred]
> > > ColorConverter c = new ColorConverter();
> > > Color clr = (System.Drawing.Color)(c.ConvertFromString(s));
> > > bool b2 = clr.IsNamedColor; //Returns false
> > >
> > > Thanks in advance,
> > >
> > > Tim
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]