Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Automatically size column widths in a grid
Message
De
11/09/2003 20:25:41
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00826986
Message ID:
00828374
Vues:
14
Hi Rich,

Thanks for the very comprehensive reply and info! That did it!

Regards
Dennis

>>Is there a way to automatically size column widths in a grid (probably in the Init event?) by just supplying a property with a comma delimited list of fields? The columns must in a way be wide enough to contain the whole field width?
>
>Yes you can size column widths in code, but no, not with a comma delimited list.
>
>You would usually do it with a loop, checking the controlsource of the columns (or assigning them in the loop), checking the field size of that controlsource, and multiplying by FONTMETRIC(6,Grid.FontName,Grid.FontSize) to get the appropriate column width.
FOR lnColNum = 1 to grdMyGrid.ColumnCount
>	WITH grdMyGrid.Column[lnColNum]
>		.ControlSource = FIELD(lnColNum, "MyTable")
>		.Width = FSIZE(FIELD(lnColNum, "MyTable"), "MyTable") * FONTMETRIC(6, grdMyGrid.FontName, grdMyGrid.FontSize)
>	ENDWITH
>ENDFOR
>
>If you have a known list of widths you want to use (you must, if you wanted to use a comma-delimited list), you could just say:
WITH grdMyGrid
>	Column1.Width = 35
>	Column2.Width = 70
>	Column3.Width = 57
>ENDWITH
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform