LISTVIEW问题(50分)

  • 主题发起人 主题发起人 dream_wo
  • 开始时间 开始时间
D

dream_wo

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何渲染LISTVIEW中某个单元格的颜色?
 
procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView;
Item: TListItem;
SubItem: Integer;
State: TCustomDrawState;
var DefaultDraw: Boolean);
begin
if assigned(item) then
if (item.Index+subitem)=2 then
ListView1.Canvas.Brush.Color:=clred
else
ListView1.Canvas.Brush.Color:=clwhite;
end;
 
procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem;
State: TCustomDrawState;
var DefaultDraw: Boolean);
var
cData: Integer;
cType: Byte;
begin
cData := Integer(Item.Data);
ExtractProductType(cData, cType);
with Sender.Canvasdo
Font.Color := defProductColors[cType];
DefaultDraw := True;
end;

procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView;
Item: TListItem;
SubItem: Integer;
State: TCustomDrawState;
var DefaultDraw: Boolean);
begin
with Sender.Canvasdo
if SubItem = 1 then
Brush.Color := clInfoBk
else
if SubItem = 2 then
Brush.Color := clSilver;
else
begin
Font.Color := clGray;
{
Brush.Color := clSilver;
}
end;
DefaultDraw := True;
end;
 
接受答案了.
 
谢谢各位!xiammy,不好意思,结贴后才看到你的回复!下次有机会一起给分!呵呵![:D]
 
后退
顶部