private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected); int index = e.Index; Graphics g = e.Graphics; Color color; if (selected == true) { color = Color.Red; } else { color = Color.Pink; } /* Draw Background */ Color borderColor = Color.Black; g.DrawRectangle(new Pen(borderColor), e.Bounds); g.FillRectangle(new SolidBrush(color), e.Bounds); /* Draw Item Text */ g.DrawString(listBox1.Items[e.Index].ToString(), e.Font, new SolidBrush(Color.Black), e.Bounds, StringFormat.GenericDefault); e.DrawFocusRectangle(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)