Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Automatically size column widths in a grid
Message
De
08/09/2003 07:15:49
 
 
À
08/09/2003 02:53:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00826986
Message ID:
00827011
Vues:
16
This message has been marked as the solution to the initial question of the thread.
Hello Dennis.

Is there a way to automatically size column widths in a grid (probably in the Init event?)

As the others have said, this is native in VFP 8. If you are using an earlier version, this code should help get you started.
LOCAL lcFontStyle

lcFontStyle = ''
FOR EACH loColumn IN THis.Columns
  *** Get the font style
  WITH loColumn
    lcFontStyle = lcFontStyle + IIF( .FontBold, 'B', '' )
    lcFontStyle = lcFontStyle + IIF( .FontItalic, 'I', '' )
    lcFontStyle = lcFontStyle + IIF( .FontOutline, 'O', '' )
    lcFontStyle = lcFontStyle + IIF( .FontShadow, 'S', '' )
    lcFontStyle = lcFontStyle + IIF( .FontUnderline, 'U', '' )
    
    *** Set the width according to the underlying data
    .Width = LEN( EVALUATE( .ControlSOurce ) ) * FONTMETRIC( 6, .FontName, .FontSize, lcFontStyle )
  ENDWITH
ENDFOR
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform