edshoro
asked on
Convert string to system.drawing.color
I am trying to change the color of a control from a srting value in a sql database.
The test value in the field is "black" as a string. I can not seem to convert the string to system.drawing.color.
Below is my code
Dim labelcolor As System.Drawing.Color
Try
Dim strSQL As String = "Select * from startup"
Dim myConnection As New SqlConnection(connectionst ring)
Dim sqlCmd As New SqlCommand(strSQL)
Dim sqlReader As SqlDataReader
sqlCmd.Connection = myConnection
myConnection.Open()
sqlReader = sqlCmd.ExecuteReader
If (sqlReader.Read()) Then
labelcolor = ctype (sqlReader("headerarea2",S ystem.Draw ing.Color) )
HeaderLabel.BackColor = labelcolor
End If
Catch exp As Exception
lblerror.Text = exp.ToString
End Try
The test value in the field is "black" as a string. I can not seem to convert the string to system.drawing.color.
Below is my code
Dim labelcolor As System.Drawing.Color
Try
Dim strSQL As String = "Select * from startup"
Dim myConnection As New SqlConnection(connectionst
Dim sqlCmd As New SqlCommand(strSQL)
Dim sqlReader As SqlDataReader
sqlCmd.Connection = myConnection
myConnection.Open()
sqlReader = sqlCmd.ExecuteReader
If (sqlReader.Read()) Then
labelcolor = ctype (sqlReader("headerarea2",S
HeaderLabel.BackColor = labelcolor
End If
Catch exp As Exception
lblerror.Text = exp.ToString
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
System.Drawing.Color.FromN