Board index » delphi » Help: TListView SubItems Don't Show on OwnerDraw
jacob muntner
![]() Delphi Developer |
Sun, 08 Feb 2004 04:43:55 GMT
Help: TListView SubItems Don't Show on OwnerDraw
Hi All
I have a ListView(vsReport,Grid), with 6 Columns. i Add the Items and SubItems from a File Loaded, within another handler. EveryThing works fine if OwnerDraw is False. now, i want Subitems 2..4 to be checked for none '0', and show them in Red. i add the following: ------ procedure TForm1.ListViewCustomDrawSubItem(Sender: TCustomListView; Item: TListItem; SubItem: Integer; State: TCustomDrawState; var DefaultDraw: Boolean); var R :TRect; I: Integer; S: String; begin ListView.Canvas.Font := ListView.Font; ListView.Canvas.Brush.Color := ListView.Color; R := Item.DisplayRect(drBounds); for i := 0 to SubItem do R.Left := R.Left + ListView.Columns[i].Width; S := Item.SubItems[SubItem]; if (SubItem > 1 ) and (S <> '0') then ListView.Canvas.Font.Color := clRed Else ListView.Canvas.Font.Color := clBlack; ListView.Canvas.FillRect(R); ListView.Canvas.TextOut(R.Left,R.Top,S); DefaultDraw := False; end; procedure TForm1.ListViewCustomDrawItem(Sender: TCustomListView; |