procedure TFrm_XBSC_Bank.ADOTab_BankAfterOpen(DataSet: TDataSet);
var
i,colwidth,max:Integer;
begin
colwidth:=5;
max:=5;
Dataset.First;
for i:=0 to Dbgrd_Tab.Columns.Count-1 do
begin
colwidth:=5;
max:=5;
Dbgrd_Tab.Columns.BeginUpdate ;
Dataset.First;
while not dataset.Eof do
begin
colwidth := Dbgrd_Tab.Canvas.TextWidth(Dbgrd_Tab.Columns.Items.Field.AsString);
Max:=math.Max(colwidth,max);
dataset.Next;
end;
if (Max < Dbgrd_Tab.Canvas.TextWidth(Dbgrd_Tab.Columns.Items.Title.Caption)) or (colwidth = 0) then
Dbgrd_Tab.Columns.Items.width := Dbgrd_Tab.Canvas.TextWidth(Dbgrd_Tab.Columns.Items.Title.Caption)+20
else
Dbgrd_Tab.Columns.Items.width := max+20;
Dbgrd_Tab.Columns.EndUpdate;
end;
end;