It seems to use default color from Windows settings which is blue by default. Let\'s say I want to change it to red permanently. I\'m using Winforms.
Thanks in advan
I have the same problem.
Unfortunately my datasource is a List of Entity Class. So I have the same code with the accepted answer above but with minor modification to select the exact property on my Class that I need on DrawString for my ListBox:
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();
//This is my modification below:
e.Graphics.DrawString(ctListViewProcess.Items.Cast().Select(c => c.strPropertyName).ElementAt(e.Index), e.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
e.DrawFocusRectangle();