Saving ForeColor to DB

JDYoder

Centurion
Joined
Nov 18, 2003
Messages
144
In VB6, ForeColor could translate into a single numeric value, which I then saved into my DB. With VB.Net, I still need to save ForeColor, however, I can't cast a Color to a number or vice versa. Is my only option to save the individual R, G, and B values of a control's .ForeColor property?
 
P.S. I can't even figure out how to change a forecolor's label to any other color thru code. Does anyone know how?
 
Code:
label1.ForeColor.ToArgb()
will return an integer - should do the trick.

to get a colour back from this integer you could do
Code:
label1.ForeColor= System.Drawing.Color.FromArgb(integer here)
 
I was close. I had ToArgb worked out, but for the other I had...

Label1.ForeColor.FromArgb(#)

... which I thought should work. But I see now that FromArgb simply returns a value and does not alter the object, which is why it should be as you posted with...

Label1.ForeColor = System.Drawing.Color.FromArgb(#)

Thanks. :)
 
Back
Top