...change the DefaultRowHeight of a TDBGrid?

Author: Thomas Stutz

Category: VCL

// 1. Way: Derive a new Type: TMyDBGrid

type
  
TMyDBGrid = class(TDBGrid)
  public
    property 
DefaultRowHeight;
  end;

var
  
Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.FormCreate(Sender: TObject);
begin
  
DbGrid1.Canvas.Font.Size := 13;
  TMyDBGrid(DBGrid1).DefaultRowHeight := DBGrid1.Canvas.TextHeight('MMMMM') + 4;
end;


// 2. Way: Make a TypeCast:

procedure TForm1.Button1Click(Sender: TObject);
begin
  
DBGrid1.DataSource.DataSet.DisableControls;
  TStringGrid(DBGrid1).DefaultRowHeight := 55;
  DBGrid1.DataSource.DataSet.EnableControls;
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base