在CustomDrawItem事件里写代码
procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
with sender.Canvas do
begin
if pos('(3)(1)',item.SubItems[0])>0 then //这部分模糊查询+改颜色
Font.Color:=clred
else
Font.Color:=clWindowText;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i,j:integer;
item:tlistitem;
begin
listview1.Items.Clear;
for i:=0 to 99 do
begin
item:=listview1.Items.Add;
item.Caption:='Cap('+inttostr(i)+')';
for j:=1 to listview1.Columns.Count-1 do
item.SubItems.Add('Sub('+inttostr(i)+')'+'('+inttostr(j)+')');
end;
end;