>sColWidths = "0," >sFontName = .lstAssigned.FontName >iFontSize = .lstAssigned.FontSize > >FOR iColumn = 1 TO FCOUNT() > iSize = TXTWIDTH(ALLTRIM(FIELD(iColumn)), sFontName, iFontSize) > sColWidths = sColWidths + TRANSFORM(CEILING(iSize)) + "," >ENDFOR >>
sColWidths = "" sComma="" sFontName = .lstAssigned.FontName iFontSize = .lstAssigned.FontSize tm6=fontmetric(6, sFontName, iFontSize) FOR iColumn = 1 TO FCOUNT() calculate max(TXTWIDTH(ALLTRIM(eval(FIELD(iColumn))), sFontName, iFontSize)*tm6) to iSize sColWidths = sColWidths+sComma + TRANSFORM(CEILING(iSize)) sComma=", " ENDFORNote that I'm taking eval() of the column, so it would measure the length of the actual content, not of the column's name, and I'm doing a Calculate Max() of it, so it would find the maximal length for all records, not just the current one. And the tm6 is the average character width that I forgot last time.