Re: Saving Colors to a db

Fabian Schmied <[email protected]> Wed, 4 Jul 2007 09:21:02 +0200
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
> Thanks.  I have used serialization for - as you say - more complex
> objects.  I didn't realize that the Color structure was serializable.
> For the Colors the user can set, they can choose named or unnamed
> colors.  However, there are many that need to be saved and there is not
> a lot of database interaction.  I think I'll give your method a try to
> see how it does.

I've done a quick search in the Windows Forms FAQ [1], and I've found
this: http://www.syncfusion.com/FAQ/winforms/FAQ_c85c.aspx#q805q

The FAQ claims it works with all kinds of colours, so it might help
you. However, it relies on the return value of Color.ToString, which
seems somewhat fragile to me.

The bottom line is just that you somehow need to persist the metadata
(i.e. the name) together with the color value, as you initially
suggested. Whether you do it explicitly, as a string, or via
serialization - you decide :)

Fabian

[1] http://www.syncfusion.com/FAQ/winforms/default.aspx