Solved

Convert string to system.drawing.color

Posted on 2006-07-15
2
2,267 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now