Author: Tomas Rutkauskas
Does anyone know how to use the OnDraw methods in the TListView - vsReport? I want
to draw both the list item and the list item's sub-items, but it seems to me that
the OnDraw only gets called on the item. I have tried all the draw methods but
cannot realy figure out how to draw in the subitems rect.
Answer:
You are right, it gets called by the TListItem but since you have the TListItem,
you can draw the subitems as well. Example DrawItem:
1 { ... }2 if Item.Index = 0 then3 Sender.Canvas.Brush.Color := clRed
4 else5 Sender.Canvas.Brush.Color := clYellow;
6 Sender.Canvas.FillRect(Rect);
7 for x := 0 to TListView(Sender).Columns.Count - 1 do8 if x = 0 then9 Sender.Canvas.TextOut(Rect.Left + 2, Rect.Top, Item.Caption)
10 else11 Sender.Canvas.TextOut((Rect.Left + 2) + Sender.Column[x].Width,
12 Rect.Top, Item.SubItems.Strings[x - 1]);
13 { ... }