type array of integer.
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
///////Begin 保留
if XXX[Column.Field.Index] < Canvas.TextWidth(Column.Field.DisplayText) then
XXX[Column.Field.Index] := Canvas.TextWidth(Column.Field.DisplayText);
///////End 保留
end;
伴水早回答过这个问题了。
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
///////Begin 保留
if XXX[Column.Field.Index] < Canvas.TextWidth(Column.Field.DisplayText) then
XXX[Column.Field.Index] := Canvas.TextWidth(Column.Field.DisplayText);
///////End 保留
end;
伴水早回答过这个问题了。
begin
DBGrid1.Columns[i].Width:=60;
end;
将每行宽设为60,具体的你自己去定义吧