我们可以设定一个字段的值,用以判断用什么颜色显示listview的颜色,例子如下
procedure TMainForm.ListView2CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
if item.SubItems.Strings[7] = Edit11.Text then
begin
item.listview.Canvas.Brush.Color:=clwhite;
item.ListView.Canvas.Font.Color:=clblack;
end
else
begin
item.ListView.Canvas.Brush.Color:=clred;
item.ListView.Canvas.Font.Color:=clwhite;
end;
end;