2个回答
展开全部
TDBGrid的祖先类之一TCustomGrid有一个未公开属性:DefaultRowHeight。改变它就可以达到你的目的。所以应该从TDBGrid派生一个子类并公开该属性:
TMyDBGrid = class(TDBGrid)
published
property DefaultRowHeight;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DBGrid1 := TMyDBGrid.Create(Self);
with DBGrid1 do
begin
Parent := Self;
Left := 50;
Top := 50;
DataSource := DataSource1;
DBGrid1.DefaultRowHeight := 30;
end;
end;
TMyDBGrid = class(TDBGrid)
published
property DefaultRowHeight;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DBGrid1 := TMyDBGrid.Create(Self);
with DBGrid1 do
begin
Parent := Self;
Left := 50;
Top := 50;
DataSource := DataSource1;
DBGrid1.DefaultRowHeight := 30;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询