ColWidth d'un TStringGrid
Bonsoir,
J'ai un problème avec une fonction de redimensionnement de colonne.
J'ai fait une petite fonction pour faire le travail (qui fonctionne très bien d'ailleurs) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
procedure AutoSizeCol(Col: integer);
var
Width : integer;
Max : integer;
i : integer;
begin
Max := 0;
for i := 0 to fStringGrid.RowCount - 1 do
begin
Width := fStringGrid.Canvas.TextWidth(fStringGrid.Cells[Col,i]);
if Width > Max then
begin
Max := Width;
end;
end;
fStringGrid.ColWidths[Col] := Max + 15;
end; |
Donc cette procedure redimensionne automatiquement la colonne passé en paramètre ...
Le problème est que lors de l'appelle de celle-ci au FormShow ou FormCreate et lors d'un appel à l'aide d'un bouton, les valeurs sont différentes.
Par exemple : OnShow : Max + 15 = 106; OnButton1Click : Max + 15 = 116;
Comment est-ce possible?