Solved

Convert string to system.drawing.color

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 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