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.:-(