I want to color one row in gray and the other in white.
I have the following code but there is white space of vertical lines of columns in Windows 7.
How do I color all rows?
procedure TForm2.Update_ListBoxCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
if Item.Index mod 2=0
then
begin
Sender.Canvas.Font.Color:=clBlack;
Sender.Canvas.Brush.Color:=$F6F6F6;
end
else
begin
Sender.Canvas.Font.Color:=clBlack;
Sender.Canvas.Brush.Color:=clWhite;
end;
end;
Set
OwnerDraw
totrue
and addScreenshot http://privat.rejbrand.se/listviewrowcolors.png
In the above example, the first column is left-aligned and the two other are centered.
If you only have one column, that is, no subitems: