[英]Change color of DBGrid row
如何更改最新的rec颜色dbgrid?
if (Sender as TDBGrid).DataSource.DataSet.RecNo = (Sender as TDBGrid)
.DataSource.DataSet.RecordCount then
begin
Canvas.Brush.Color := $00C66F71;
end;
(Sender as TDBGrid).DefaultDrawColumnCell(Rect, DataCol, Column, State);
使用OnDrawColumnCell
财产TDbGrid
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (Sender as TDBGrid).DataSource.DataSet.RecNo = (Sender as TDBGrid).DataSource.DataSet.RecordCount then
begin
//change color of row
DBGrid1.Canvas.Brush.Color:=$00C66F71;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
要更改文本的颜色,请使用:
DBGrid1.Canvas.Font.Color:=clRed;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
在你的代码中
Canvas.Brush.Color:=$00C66F71;
是Canvas
的的TForm
,不是Canvas
中的TDbgrid
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.