Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Vcl.DBGrids.TDBGrid.OnDrawDataCell
Occurs when the grid needs to paint a cell if the State property of Columns is csDefault.
Do not write an OnDrawDataCell event handler. OnDrawDataCell is obsolete and included for backward compatibility. Instead, write an OnDrawColumnCell event handler.
var
LBmp: TBitmap;
procedure TForm1.Button1Click(Sender: TObject);
begin
DBGrid1.DefaultDrawing := not DBGrid1.DefaultDrawing;
//
if DBGrid1.DefaultDrawing then
Caption := 'DBGrid1.DefaultDrawing = true'
else
Caption := 'DBGrid1.DefaultDrawing = false';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
CountryTable.Active := not CountryTable.Active;
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if DataCol = 0 then
begin
Column.Color := clBlue;
Column.Font.Color := clYellow;
//
// ImageList1.Draw(DBGrid1.Canvas, 2, Rect.Top, 0, true);
//
if ImageList1.GetBitmap(10, LBmp) then
DBGrid1.Canvas.Draw(Rect.Left, Rect.Top, LBmp);
//
DBGrid1.Canvas.TextOut(Rect.Left + LBmp.Width, Rect.Top, Column.Field.AsString);
end
else
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
LBmp := TBitmap.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
LBmp.Free;
end;