Hello, I have some code to change how listbox act. I can change the color of text, but I am unable to change the color of the background of each line.
This is in a for loop for every of my lines
LBLines is an array of string store in a global variable
if (LBLines[e.Index] != "None")
{
e.Graphics.FillRectangle(new SolidBrush(Color.FromName(LBLines[e.Index])),
e.Bounds.X,e.Bounds.Y,e.Bounds.Width,e.Bounds.Height);
}
This will color EVERY lines of the same color, even those listed as "None", thou what I need is that they stay same color as default background color.
EDIT: Comparaison is not the problem, problem come from the e.Graphics.FillRectangle. It seems to color ALL the lines spaces, regardless of the one I am drawing.
EDIT2: Modified code to show that h was equal to e.Index