private void Form1_Load(object sender, EventArgs e)
{
listBox1.DataSource = new string[] { "one", "two", "three" };
listBox1.DrawItem += listBox1_DrawItem;
listBox1.DrawMode = DrawMode.OwnerDrawVariable;
}
void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index < 0) return;
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
e = new DrawItemEventArgs(e.Graphics,
e.Font,
e.Bounds,
e.Index,
e.State ^ DrawItemState.Selected,
e.ForeColor,
Color.Yellow);
e.DrawBackground();
e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
e.DrawFocusRectangle();
}
reference :
change ListBox selection background color [
^]