maxfax
maxfax

Reputation: 4305

Delphi: paint column of list view

I draw a list view with OwnerDraw. I need to paint the first column. But I cannot understand how.

I tried:

procedure TFrame6.DownloadListCustomDraw(Sender: TCustomListView;
  const ARect: TRect; var DefaultDraw: Boolean);
    var
      R: TRect;
    begin                  
      DefaultDraw := False;
      Sender.Canvas.Brush.Color := $F7F7F7;
      Sender.Canvas.Brush.Style := bsSolid;
      R := ARect;
      R.Right := ListView_GetColumnWidth(DownloadList.Handle, DownloadList.Columns[0].Index);
      Sender.Canvas.FillRect(R);  
      DefaultDraw := True;
    end;

But I draw over items. How to draw correctly, items and a background?

Thanks!

Upvotes: 1

Views: 2867

Answers (2)

ThinkJet
ThinkJet

Reputation: 6735

Summary from comments:

I suggest you to read this delphiDabbler article and hope that it contains enough information to resolve your problem. E.g. Example 1 shows how to change background and Example 4 shows point where item appearance can be changed.

Small tip: don't restore DefaultDraw to True at the end of the handler if you don't want text to be drawn.

Upvotes: 1

XBasic3000
XBasic3000

Reputation: 3486

I suggest you use VirtualStringTree if you want a lot of customization on the list. Its easy to use and almost anything is possible and most of all freeware. The component can be downloaded at Soft-Gems and few example can be found here

Upvotes: 1

Related Questions