日期:2014-05-17 浏览次数:20472 次
private void listBox_DrawItem(object sender, DrawItemEventArgs e)
{
Brush FontBrush = null;
ListBox listBox = sender as ListBox;
if (e.Index > -1)
{
switch (listBox.Items[e.Index].ToString())
{
case "Critical": FontBrush = Brushes.Brown; break;
case "Major": FontBrush = Brushes.Red; break;
case "Minor": FontBrush = Brushes.Orange; break;
case "Warning": FontBrush = Brushes.Yellow; break;
default: FontBrush = Brushes.Black; break;
}
e.DrawBackground();
e.Graphics.DrawString(listBox.Items[e.Index].ToString(), e.Font, FontBrush, e.Bounds);