Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sizing columns in a grid
Message
De
29/05/1999 03:54:08
 
 
À
28/05/1999 16:12:18
Koos Veel
Gamma Research
Aruba
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00224128
Message ID:
00224287
Vues:
19
>Hello,
>
>We use VFP 6.0. In one of our forms, we have a grid that can have more than one cursor as it's controlsource. Columncount is on -1.
>
>The sequence of the fields in the cursors determines the sequence of columns (I think.) The problem is that in some cases the width of the columns is not right.
>Is there a way to change this??
>

I'm assuming that you want to do this at runtime, and that while the sequence of fields is not known ahead of time, the names and proper widths of all the fields that might be used is. You could try spinning through the grid's Column collection in the Grid's Init, and for each column, examine the column's ControlSource and set the Column's Width property, something like:
LOCAL cColCtlSrc, nColWidthDesired
thisform.LockScreen = .t.
FOR Each oColumn IN this.Columns
   cColCtlSrc = UPPER(oColumn.ControlSource)
   cColCtlSrc = SUBST(cColCtlSrc,RAT('.',cColCtlSrc)+1))  && strip alias if present
   nColWidthDesired = oColumn.Width
   DO CASE
   CASE cColCtlSrc = "FOO"
      nColWidthDesired = <i>some numeric value</i>
   CASE cColCtlSrc = "BAR"
      nColWidthDesired = <i>some other numeric value</i>
   CASE  cColCtlSrc = "MUMBLE"
      nColWidthDesired = <i>Yet another numeric value</i>
   *  add a case for any field whose width needs changing
   ENDCASE
   oColumn.Width = nColWidthDesired
ENDFOR
thisform.LockScreen = .f.
This isn't the only solution - you could build a table with field names and values and data-drive the process. You only need to examine the column controlsource values that would need to be changed in the DO CASE...ENDCASE; the default value assigned will be used if you don't override it.

This clearly won't work the way I wrote it if you have several possible source fields with the same name that have different desired widths, since this code couldn't differentiate between the two.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform