Hi,
I am trying to do something like this within ListBox.DrawItem:
e.DrawBackground();
// Draw an icon image.
e.Graphics.DrawImage(myImage, 0, 0, myImage.Width, myImage.Height);
// Alternate row color.
if (e.Index % 2 == 0)
{
Brush bgBrush = new SolidBrush(Color.LightGray);
e.Graphics.FillRectangle(bgBrush, 0, 0, e.Bounds.Width, e.Bounds.Height);
bgBrush.Dispose();
}
However the drawing of the image and alternating of the row color only works on the very first item displayed on the very top of the ListBox, not the items below it. If I scroll up continously however (on a ListBox with a lot of items in it) the image begins to get painted on the list items and the background color begins alternate on the items.
Any ideas on how to resolve this???