var
x, y, w: integer;
s: string;
MaxWidth: integer;
begin
with StringGrid1 do
ClientHeight := DefaultRowHeight * RowCount + 5;
with StringGrid1 do
begin
for x := 0 to ColCount - 1 do
begin
MaxWidth := 0;
for y := 0 to RowCount - 1 do
begin
w := Canvas.TextWidth(Cells[x,y]);
if w > MaxWidth then
MaxWidth := w;
end;
ColWidths[x] := MaxWidth + 5;
end;
end;
end;
|