procedure TfrmTyxwbl.DBGridEh5DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
begin
with (Sender as TDBGridEh).Canvas do
begin
if ADOQuery5.FieldByName('IsSel').AsBoolean then
begin
Brush.Color:=clSkyBlue;
FillRect(Rect);
DBGridEh5.DefaultDrawColumnCell(Rect,DataCol,Column,
[gdFixed,gdFocused,gdSelected]);
end
else
begin
Brush.Color:=clBtnFace;
FillRect(Rect);
DBGridEh5.DefaultDrawColumnCell(Rect,DataCol,Column,
[gdFixed,gdFocused,gdSelected]);
end;
end;
end;
with (Sender as TDBGridEh).Canvas do
begin
if ADOQuery5.FieldByName('IsSel').AsBoolean then
begin
Brush.Color:=clSkyBlue;
FillRect(Rect);
DBGridEh5.DefaultDrawColumnCell(Rect,DataCol,Column,[gdFixed,gdFocused,gdSelected]);
end
else
begin
Brush.Color:=clBtnFace;
FillRect(Rect);
DBGridEh5.DefaultDrawColumnCell(Rect,DataCol,Column,[gdFixed,gdFocused,gdSelected]);
end;
end;
begin
if TableField.AsInteger < 0 then
DBGrid.Canvas.Font.Color := clRed
else
DBGrid.Canvas.Font.Color := clBlack;
DBGrid.DefaultDrawColumnCell(...);
end;
表中加字段isSel,如果双击后则为true
with (Sender as TDBGridEh).Canvas do
begin
if ADOQuery1.fieldbyname('Xwlx').AsString='通用类询问笔录' then
if ADOQuery1.fieldbyname('isSel').AsBoolean=true then
begin
Brush.Color :=clSkyBlue;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, Column.Field.DisplayText);
end
else
begin
Brush.Color :=clBtnFace;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, Column.Field.DisplayText);
end;
end;