469,621 Members | 1,856 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

Setting Control colors

I have an application that allows the user to select fore and back ground
colors for command buttons. I use the dialog to select the colors and store
the value returned in the db as a string. For standard colors the db values
are "white" etc. For custom colors the values are "ff808040" etc.

When I try to load these values from the db and set the controls colors I am
getting an error. The statement is
control.forecolor = db.fields("forecolor").value
the error returned is
Specified cast is not Valid.

I have tried using ctype but it then tells me the cast is not allowed.

Am I storing the selected value in the db using the correct type?
How can I set these values

Cliff
Nov 20 '05 #1
2 1129
Hi,

Dim clr As Color =
System.Drawing.ColorTranslator.FromHtml("#FF808040 ")
Button1.BackColor = clr

Ken
-----------------
"Cliff Lane" <C_*******@email.msn.com> wrote in message
news:eT*************@TK2MSFTNGP09.phx.gbl...
I have an application that allows the user to select fore and back ground
colors for command buttons. I use the dialog to select the colors and
store
the value returned in the db as a string. For standard colors the db
values
are "white" etc. For custom colors the values are "ff808040" etc.

When I try to load these values from the db and set the controls colors I
am
getting an error. The statement is
control.forecolor = db.fields("forecolor").value
the error returned is
Specified cast is not Valid.

I have tried using ctype but it then tells me the cast is not allowed.

Am I storing the selected value in the db using the correct type?
How can I set these values

Cliff

Nov 20 '05 #2
Dim SomeColor As System.Drawing.ColorTranslator
Dim myColor = SomeColor.FromHtml(db.fields("forecolor").ToString )
myControl.BackColor = myColor
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Alex Maghen | last post: by
reply views Thread by Bryce Budd | last post: by
6 posts views Thread by vijai.kalyan | last post: by
4 posts views Thread by K Viltersten | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.