开发者

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!


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜