procedure TForm1.cxGrid1DBTableView1CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
//Item确定列(ID列的索引),RecordViewInfo确定行(Index行的索引)
//可以定位到某一行改变颜色
{if (AViewInfo.Item.ID = 0) and (AViewInfo.RecordViewInfo.Index = 0) then
ACanvas.Brush.Color := clred;}
//可以根据条件值确定改变某行颜色
if (trim(AViewInfo.RecordViewInfo.GridRecord.Values[4]) = 'HTT')
and (AViewInfo.Item.ID = 4) //确定到某一列,如果不加确定是某行底色
then
ACanvas.Brush.Color := clred;
end;
根据条件改变cxGrid行与列颜色
最新推荐文章于 2020-01-10 14:35:16 发布
本文介绍如何使用 Delphi 的 cxGrid 控件实现基于条件的单元格背景色高亮显示。通过定制 DBTableView1CustomDrawCell 方法,可根据单元格内容或特定列的值来改变行的颜色。
1146

被折叠的 条评论
为什么被折叠?



