1
可能重复:
Background color of a ListBox item (winforms)更改列表框的背景颜色
我有一个列表框,对于每一个坐标,我需要有不同的颜色。恩。
23,34 //red background
56,78 //green background
90,2 // yellow background
代码:
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;
}
}
我使用Foreground
了,但如何改变Background
颜色为每个坐标?