控制listbox的字体颜色
//控制listbox的字体颜色
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
if (e.Index > -1)
{
SolidBrush brsr = new SolidBrush(Color.Red);
SolidBrush brsg = new SolidBrush(Color.Green);
SolidBrush brsb = new SolidBrush(Color.Blue);
if (e.Index % 2 == 0)
e.Graphics.DrawString(Convert.ToString(listBox1.Items[e.Index]), e.Font, brsr, e.Bounds);
//else if (e.Index % 3 == 0)
// e.Graphics.DrawString(Convert.ToString(listBox1.Items[e.Index]), e.Font, brsg, e.Bounds);
else
e.Graphics.DrawString(Convert.ToString(listBox1.Items[e.Index]), e.Font, brsb, e.Bounds);
}
}