Question : ASPNET/C#  - Color question

Hello all,

I need to take 10 light colors in the blues and then I want to loop through a listbox and set the item.backcolor to the color.  So I need to in that loop set the next color through the 10 and then start again at the first color through the 10 again.

Any idea?

Answer : ASPNET/C#  - Color question

Hi,

Try below code:

string[] strArray = new string[] { "#BDD8E8", "#ADD8E8", "#CDD8E8", "#DDD8E8" };
        int j = 0;
        for (int i = 0; i < ListBox1.Items.Count; i++)
        {
            if (j == strArray.Length - 1)
                j = 0;

            ListBox1.Items[i].Attributes.Add("style", "background-color:" + strArray[j]);
            j++;
        }

In strArray variable store your color codes and try. Here I stored only four color codes. you can store ten color codes.
Random Solutions  
 
programming4us programming4us