Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automatically size column widths in a grid
Message
From
08/09/2003 07:15:49
 
 
To
08/09/2003 02:53:07
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00826986
Message ID:
00827011
Views:
17
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform