Possible Duplicate:
Background color of a ListBox item (winforms)
I have a ListBox, that for every coordinates I need to have different colours. ex.
23,34 //red background
56,78 //green background
90,2 // yellow background
Code:
for (int i = 0; i < il_kl; i++)
{
int il_pkt = Klastry[i].Punkty.Count;
string color = lista_kolor[i];
Brush mybrush = (Brush)new BrushConverter().ConvertFromString(color);
for (int j = 0; j < il_pkt; j++)
{
x = Klastry[i].Punkty[j].X;
y = Klastry[i].Punkty[j].Y;
_mn.kolekcje_wsp.Items.Add(x + " , " + y);
_mn.kolekcje_wsp.Foreground = mybrush;
}
}
I’m using Foreground now, but how to change the Background color for every coordinates?
You can try the following and see if it works for you
Probably the only way to accomplish that is to draw the items yourself.
Set the DrawMode to OwnerDrawFixed
and code something like this on the DrawItem event: