Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 118,589 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 816 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Color Combobox

 
Reply to this topicStart new topic

Color Combobox, How to set different background Colors for each items in Combobox wit

hildaelavarasi
post 7 Aug, 2008 - 03:03 AM
Post #1


New D.I.C Head

*
Joined: 20 Jun, 2008
Posts: 4


Hi.....

How to set different background Colors for each items in Combobox with windows application C#,
ie)each items have to display different Colors within a Combobox..

Actually i got Colors..it displayed Combobox Background Color..but i want Each items have to display Corresponding Colors...


my Code is:

CODE
  private object colors(int a)
        {
            string color1="";
            if (a == 1)
            {
                color1 = "FF";
           }
           if (a == 2)
           {
               color1 = "CC";
           }
          if (a == 3)
           {
               color1 = "99";
           }
          if (a == 4)
           {
               color1 = "66";
           }
          if (a == 5)
           {
               color1 = "33";
           }
          if (a == 6)
           {
               color1 = "00";
           }
           return color1;
private void ColorCombo_Load(object sender, EventArgs e)
        {
          
            string newcolors = "";
            for (avar = 1; avar <= 6; avar++)
            {
                for (bvar = 1; bvar <= 6; bvar++)
                {
                    for (cvar = 1; cvar <= 6; cvar++)
                    {                        
                    newcolors = "#" + colors(avar) + colors(bvar) + colors(cvar);
                      //  textBox1.Text = newcolors;
                        comboBox1.Items.Add(newcolors);
                        comboBox2.Items.Add(newcolors);
}
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string newcolor = Convert.ToString(comboBox1.Text);
            string hex = newcolor.Substring(newcolor.Length - 6);
            a = Convert.ToInt32(hex.Substring(0, 2), 16);
            b = Convert.ToInt32(hex.Substring(2, 2), 16);
            c = Convert.ToInt32(hex.Substring(hex.Length - 2), 16);
           comboBox1.BackColor = Color.FromArgb(a, b, c);
             }


Kindly Help me Plz.:-(




User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/11/08 07:58PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month