You need to set the DrawMode in order to fire DrawItem events:
private void FrmMain_Shown(object sender, EventArgs e)
{
myListBox.Items.Add("A - Cyan");
myListBox.Items.Add("B - Magenta");
myListBox.Items.Add("C - Yellow");
myListBox.Items.Add("D - Black");
myListBox.DrawMode = DrawMode.OwnerDrawFixed;
}
private void MyListBox_DrawItem(object sender, DrawItemEventArgs e)
{
if (sender is ListBox lb)
{
e.DrawBackground();
string s = lb.Items[e.Index].ToString();
Brush brush = Brushes.Green;
switch (s[0])
{
case 'A': brush = Brushes.Cyan; break;
case 'B': brush = Brushes.Magenta; break;
case 'C': brush = Brushes.Yellow; break;
case 'D': brush = Brushes.Black; break;
}
e.Graphics.DrawString(s, e.Font, brush, e.Bounds, StringFormat.GenericDefault);
}
}
Will colour each item differently.