Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Losing column widths in grid
Message
De
08/09/1998 01:05:14
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00133860
Message ID:
00133940
Vues:
14
Carl,
Grid formatting an preserving format is sometimes tricky. Generally setting recordsource = "", then when data is ready to alias preserves format. To be sure it's preserved, done best with saving format and then restoring it :
* A grid class keeping its columnwidths in a custom array prop
*Init code
with this
* Could be acustom method - savecolumnwidths
 if .ColumnCount > 0
    dimension .aColumnWidths[.ColumnCount]
    for each oColumn in .columns
	.aColumnWidths[oColumn.ColumnOrder]=oColumn.width
	oColumn = .NULL. && Safety belt against GPF
    endfor
 endif
* Could be acustom method - savecolumnwidths

* Recordsource can now freely change, requery etc
* Better 
* .columncount = -1
* before recordsource change
* Could be acustom method - restorecolumnwidths
 for each oColumn in .columns
   if oColumn.ColumnOrder <= alen(.aColumnWidths,1) ;
      and type(".aColumnWidths[oColumn.ColumnOrder]")="N"
      oColumn.width = this.aColumnWidths[oColumn.ColumnOrder]
   endif	
   oColumn = .NULL. && Safety belt against GPF
 endfor
* Could be acustom method - restorecolumnwidths
endwith
Cetin


>Barbara,
>Thanks for your input. Having read it, it made perfect sense but when I tried it the column widths were still not the same as in design view. I tried both using the D.E. and the LOAD event to open the view with NODATA. I even tried setting the parameter to a value that it could not possibly be and let it retrieve an empty data set and the column widths were still altered.
>
>Interestingly, I saved the form as a class and created another form based on that class and the column widths were fine (I didn't test this with the code I had before your patch). I don't get it.
>
>Just curious, the original form was based on a class very much like the tsMaintform class from the Tas Traders sample. Could that be a contributing factor ?
>
>--Carl
>
>>This is a known problem caused by changing the grid RecordSource property. In your case, open the view in the LOAD event or DataEnvironment, marking NoDataOnLoad to be .T. Set the RecordSource of the grid to the view on the property sheet. In the INIT() code, when you have the correct parameter, do a ReQuery() on the view.
>>
>>HTH
>>Barbara
>>
>>>I'm using a grid to display a parameterized view in a private data session with VFP5. There is one parameter for the view which is passed to the form by the calling program. The INIT method in the form receives that parameter and opens the view. It also assigns the view name to the RecordSource property of the grid.
>>>
>>>When the form displays, the column widths in the grid appear to have been altered to reflect the original field width for each field in the view. If I set the RecordSource property for the grid to the view name at design time, the colums are all altered to be very narrow (looks like about 1 screen column).
>>>
>>>My guess is that it's a matter of forcing the widths back to their design width but I'm not sure that can best be done.
>>>
>>>TIA,
>>>
>>>--Carl
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform