listview,treeview 的单行颜色控制问题(100分)

  • 主题发起人 主题发起人 windyhero
  • 开始时间 开始时间
W

windyhero

Unregistered / Unconfirmed
GUEST, unregistred user!
listview,treeview 的单行颜色动态控制问题
 
ListView1.OwnerDraw := true;

procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
inc(i);
if odd(i) then begin
listview1.Canvas.Brush.Color:=$00FEF4E7;
listview1.Canvas.FillRect(item.DisplayRect(drBounds));
end else begin
listview1.Canvas.Brush.Color:=$00F7F8F9;
listview1.Canvas.FillRect(item.DisplayRect(drBounds));
end;
end;
 
下面这个好些:

rating (2001-12-30 16:27:00)
--------------------------------------------------------------------
procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
if odd(item.Index) then
item.ListView.Canvas.Brush.Color:=$00FEF4E7
else
item.ListView.Canvas.Brush.Color:=$00F7F8F9;
end;

 
接受答案了.
 
后退
顶部