Ben's Random Mumbles

System.Drawing.Color.What?

I have started using the TallPDF.NET component to create a dynamic PDF report and bumped into a little problem when I had to specify the background colors for various parts of my report. I could use the VS.NET intellisense to give me a list of all the avalible colors, but who knows what Chartreuse looks like?

So I put together a simple Windows Form that has a comboBox and a panel, and added some code to add all the colors to the comboBox, and on SelectedIndexChanged modify the background color of the panel.

To add the colors to the comboBox:

foreach (string colourName in Enum.GetNames(typeof(KnownColor)))
{
        comboBox1.Items.Add(colourName);
}

And then add an SelectedIndexChanged event to the comboBox with the following code:

string cName = (comboBox1.SelectedItem as string);
Color newColour = Color.FromName(cName);
panel1.BackColor = newColour;

Posted: Feb 28 2003, 08:59 AM by benricho | with 2 comment(s)
Filed under:

Comments

Marco Trova said:

Are you having any problems with TallPDF.NET?
# March 5, 2004 6:58 AM

Feed Search Engine - All Fresh Articles And News Are Here said:

Pingback from  Feed Search Engine - All Fresh Articles And News Are Here

# November 25, 2007 2:20 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)