Solved

Convert string to system.drawing.color

Posted on 2006-07-15
2
2,274 Views
Last Modified: 2012-06-27
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(connectionstring)
            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",System.Drawing.Color))
                HeaderLabel.BackColor = labelcolor
               

                            End If
        Catch exp As Exception
            lblerror.Text = exp.ToString
        End Try
0
Comment
Question by:edshoro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17114515
use
System.Drawing.Color.FromName function
0
 
LVL 9

Accepted Solution

by:
zaghaghi earned 250 total points
ID: 17114518
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question