Как изменить шрифт определённой строки в DBGrid
|
"Всех денег не заработать", - огорченно сказал Билл Гейтс уходя в отставку.
|
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
// If the record's CustNo is 4711 draw the entire row with a
// line through it. (set the font style to strike out)
if (Sender as TDBGrid).DataSource.DataSet.FieldByName('CustNo').AsString = '1221' then
with (Sender as TDBGrid).Canvas do
begin
FillRect(Rect);
// Set the font style to StrikeOut
Font.Style := Font.Style + [fsStrikeOut];
Font.Color := clRed;
// Draw the cell right aligned for floats + offset
if (Field.DataType = ftFloat) then
TextOut(Rect.Right-TextWidth(Field.AsString)-3, Rect.Top+3, Field.AsString)
// Otherwise draw the cell left aligned + offset
else
TextOut(Rect.Left+2,Rect.Top+3,Field.AsString);
end;
end;
|
|