Procedure Autofitable (Agrids: TstringGrid); // Incoming TstringGrid Object, 2004/10/28, Coolslobvar I, J: Integer; MaxLenRow: Integer; Currowlen: Integer; Begin Inherited; for J: = 0 To Agrids. Colcount - 1 Do Begin Maxlenrow: = 0; for i: = 1 to Agrids.Rowcount - 1 Do Begin Currowlen: = AGRIDS.CANVAS.TEXTWIDTH (TRIM (Agrids.cells [J, I])); // Adaptive Width When the maximum width of the value is smaller than the title width, the title is wide. IF Agrids.canvas.TextWidth (Trim (Agrids.cells [J, 0]))> Currowlen Ten Currowlen: = Agrids.canvas.TextWidth (Trim (Agrids.cells [J, 0])); if Currowlen> MaxLenRow THEN BEGIN MaxLenrow: = Currowlen 5; Agrids.ColWidths [J]: = MaxLenRow; end; end; end;