Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

save colors in DB

Status
Not open for further replies.

nickske80

Programmer
Aug 2, 2003
55
0
0
BE
Hello everybody,

I am planning to add a feature to my program where I want the user to be able to choose some colors and fonts for his forms.
(background, color of the fonts, ...)

I use a access DB to save everything.
But I can 't seem to store a color in a DB and retrieve it so it can be used again as a color.

What kind of datatype should I use?

Any help would be appreciated.

To search or to post - that is the question.
To search first and to post later. THAT is the answer.
 
Hi
You can save both Font and Color as string and then later can use as
e.g
button1.Font = new Font ("Courier", 10, FontStyle.Bold);
button1.backColor=StringToColor("Red")

Public Function StringToColor(ByVal s As String) As Color
Return CType(TypeDescriptor.GetConverter(Type.GetType(Color)).ConvertFromString(s), Color)
End Function

Regards
Nouman

Nouman Zaheer
Software Engineer
MSR
 
thanx for the reply nomi.

But vb.net doesn 't seem to know the 'TypeDescriptor' - object.

Is there any way i can add it to my project?



To search or to post - that is the question.
To search first and to post later. THAT is the answer.
 
You have to import
Imports System.ComponentModel
For StringToColor to run
also the correct syntax for StringToColor is
Public Function StringToColor(ByVal s As String) As Color
Return CType(TypeDescriptor.GetConverter(GetType(Color)).ConvertFromString(s), Color)
End Function

Regards
Nouman


Nouman Zaheer
Software Engineer
MSR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top