DeniseGoodheart
asked on
Value of type string cannot be converted to System.Drawing.Color Error
Good Day:
I created a VB.NET 2005 color template form that allows the user to select a color to be used for the form text controls. The value is stored in the Public Property UserProfileColorGet() As String. For example, the user selects color A which equals color.yellow. My problem is the following code gives me an error that reads: Value of type string cannot be converted to System.Drawing.Color
Private Sub txtSO_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSO.Leave
Dim sColor As String = oCon.UserProfileColorGet
Me.txtSO.BackColor = sColor
End Sub
How can I fix this problem?
Thank You,
Denise
I created a VB.NET 2005 color template form that allows the user to select a color to be used for the form text controls. The value is stored in the Public Property UserProfileColorGet() As String. For example, the user selects color A which equals color.yellow. My problem is the following code gives me an error that reads: Value of type string cannot be converted to System.Drawing.Color
Private Sub txtSO_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSO.Leave
Dim sColor As String = oCon.UserProfileColorGet
Me.txtSO.BackColor = sColor
End Sub
How can I fix this problem?
Thank You,
Denise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Also I changed color.yellow to yellow to make it work.
-use-
Imports System.Drawing
-then replace your line-
Me.txtSO.BackColor = sColor
-with-
Me.txtSO.BackColor = Color.FromName(sColor)
Imports System.Drawing
-then replace your line-
Me.txtSO.BackColor = sColor
-with-
Me.txtSO.BackColor = Color.FromName(sColor)
ASKER
Thank you for offering to help me. You get an easy 500 points because I figured out the solution as follows:
txtSO.BackColor = System.Drawing.Color.FromN
Cheers,
Denise