procedure TFrmMain.btn1Click(Sender: TObject);
var
Lv1 : TlistView;
begin
if (Lv1.Items[i].Caption = Lv2.Items[i].Caption) and
(Lv1.Items[i].SubItems.strings[0] = Lv2.Items[i].SubItems.strings[0]) then
begin
//显示这一行(ListView这一行)的颜色为 红色;
end
end;
解决方案 »
- 使用RICHEDIT设置了字体颜色,但经常失效如何解决
- delphi+access 按时间查询时,出错了
- 跪求三层源码
- 今年过节不送礼,送礼只送社区积分!散分!
- 怎样在delphi中添加新组件?
- 微软超级漏洞,Windows2000安全虚设
- 我想打印表格式的报表,就是一行中各个数据段用竖线分开,请高手指教!(60)
- copyrect(rect,canvas,rect)有什么用呢
- !!!!!!!!!急急急!!!!!!!!!!!!!
- 安装完成后,启动应用程序时出现非法操作:database engine (error$2109);见者有分
- 求一个dll数据库窗体封装与调用的例子
- 如何用HOOK 来监视 文件的关闭? 来者有分
if Items.Caption = '红色' then
beign
ListView.Canvas.Font.Color:= clRed;
end;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var
p:trect;
begin
if cdsselected in state then
begin
listview1.Canvas.Font.Color:=clgreen;
listview1.Canvas.brush.Color:=clred;
p:=item.displayrect(drselectbounds);
listview1.Canvas.FillRect(p);
listview1.Canvas.Textout(p.Left+2,p.Top,item.Caption);
listview1.Canvas.brush.Color:=clblue;
listview1.Canvas.FrameRect(item.displayrect(drselectbounds));
defaultdraw:=false;
end;
end;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var
R: TRect;
begin
with TListView(Sender).canvas do
if cdsSelected in State then
begin
font.Style := [fsBold];
font.color := clred;
brush.Color := clgreen;
R := item.DisplayRect(drlabel);
textout(R.Left + 1, R.Top + 1, item.Caption);
defaultdraw := False;
end
else
DefaultDraw:=true;
end;
if (Lv1.Items[i].Caption = Lv2.Items[i].Caption) and
(Lv1.Items[i].SubItems.strings[0] = Lv2.Items[i].SubItems.strings[0]) then
begin
//显示这一行(ListView这一行)的颜色为 红色;
//如果满足以上条件,再绘制符合条件的这一行的颜色.
end
procedure TFrmMain.btnClick(Sender: TObject);
var
rect: TRect;
i,x:integer;
begin
if (Lv1.Items[i].Caption = Lv2.Items[i].Caption) and
(Lv1.Items[i].SubItems.strings[0] = Lv2.Items[i].SubItems.strings[0]) then
begin
rect := Lv1.Items[0].DisplayRect(drBounds) ;
Lv1.Canvas.Font.Color := clWhite;
Lv1.Canvas.Brush.Color:= clRed;
Lv1.Canvas.FillRect(rect);
Lv1.Canvas.Textout(rect.left,rect.top,Lv1.Items[0].caption); //
x:=0;
for i:=0 to Lv1.Columns.Count-2 do
begin
x:=x+Lv1.Columns[i].Width;
Lv1.Canvas.Textout(rect.Left+x,rect.Top, Lv1.Items[0].SubItems.Strings[i]);//显示SubItems文字
end;
end;
end;