DELPHI TLISTVIEW控件里添加背景色


本文整理自网络,侵删。

 

//....某一行

procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
with ListView1.Canvas.Brush do
begin
case Item.Index of
0: Color := clYellow;
1: Color := clGreen;
2: Color := clRed;
end;
end;
end;


//..某一列、某一格

procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView;
Item: TListItem; SubItem: Integer; State: TCustomDrawState;
var DefaultDraw: Boolean);
begin
inherited;
with lv3.Canvas.Brush do begin
case SubItem of
3:begin
color:=clYellow;
end else begin
color:=clWhite;
end;
end;
end;
end;

相关阅读 >>

Delphi的with…do语句的用法

Delphi winapi: getfocus - 获取当前拥有焦点的窗口的句柄

Delphi fdconnection取得excel工作表名

Delphi共享软件防破解的实用方法

Delphi android adb usb上读取设备信息

Delphi 从 twebbrowser中获得当前输入处的链接

Delphi通过loadlibrary调用其他动态库

Delphi jpg图片 旋转 切边 缩放

Delphi 上传文件到七牛,纯原生

Delphi 消息实现窗口最小化,最大化,关闭(Delphi)

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...