Re: Saving Colors to a db

Peter Osucha <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
Hmmm, I never thought of that.  How do the Web Colors, for example, show
up on non-english machines?  Perhaps I just shouldn't show the color
name, number, etc. at all and should just show the color, eh?

Peter

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps
and controls [mailto:[email protected]] On Behalf Of
Chris Anderson
Sent: Monday, July 02, 2007 4:20 PM
To: [email protected]
Subject: Re: [DOTNET-WINFORMS] Saving Colors to a db

IMO you shouldn't really be exposing the enumeration names to the user.
It certainly wouldn't help in a non-English environment ;-)

If you needed to though, you could always match it up with the value
comparing to the enum values (I'm assuming you are loading a dropdown
box or similar anyway, so this lookup wouldn't be too difficult)

> I am saving Color values to a database as integers after converting
the
> color using the ToArgb() method.  When I retrieve the color, I am
> resetting it using the FromArgb() method.  However, this doesn't
> preserve the color name if the color has a name - as shown in this
> simple test proc.
> 
>         private void Button3_Click ( object sender, EventArgs e )
>         {
>             Color col1 = Color.DarkBlue;
>             int col1int = col1.ToArgb ( );
>             Color col2 = Color.FromArgb ( col1int );
>             Console.WriteLine ( "{0}, {1}", col1, col2 );
>         }
> 
> If I desire to save and retrieve Colors to a database and to preserve
> the color name if it exists, I imagine I need to save a string of the
> name instead of the argb value?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.