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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting backcolor dynamically

Status
Not open for further replies.

DerPflug

Programmer
Mar 28, 2002
153
US
I want to pull a string containing background color information from a database and dynamically set a form's background color.
When I try to cast the string as "drawing.color" it errors out. Here's an example:


dim backcolor as object

backcolor = ds.Tables("BColor").Rows(0).Item("BackColor")
Me.BackColor = CType(backcolor, System.Drawing.Color)


Any help would be appreciated.
 
Try this:
Dim str As String = "Red"
Me.BackColor = Color.FromName(str)
Me.Refresh()

Where "Red" must be a system predefined color
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top