Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is this tip again with the grid?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00573503
Message ID:
00573556
Vues:
22
Hello Jean-Rene.

>> I need to change the record source of the grid. But this grid has 20 fields and I do not whant to reset the 20 fields. <<

One way to avoid having the grid turn into a blank grey blob is to set its RecordSource to an empty string before chamging it and then resetting it afterward. Although this will work in the simplest of cases, it is not a solution I recommend. While it will keep your grid from losing its mind, the grid's columns still lose their ControlSources and any embedded controls. So, this works if your grid uses base class headers, base class text boxes, and displays the fields from the cursor in exactly the same order as they are SELECTed. Otherwise, you have to write a lot more code to restore all the things that get lost when the grid is re-initialized.

A better solution would be to use a parameterized view as the grid's RecordSource. If this is not possible, another alternative is to use a "safe select" into an updateable cursor. All you do is give your grid a custom ResetGrid method and call it whenever you need to change its RecordSource:
*** Rebuild the cursor used as the recordSource for the grid
lcRecordSource = This.RecordSource
SELECT ( lcRecordSource )
ZAP
SELECT Yada, Nada, Blah FROM MyTable WHERE SomeCondition ;
	INTO CURSOR Temp NOFILTER
SELECT ( lcRecordSource )
APPEND FROM DBF( 'Temp' )
USE IN Temp
GO TOP IN ( lcRecordSource )
This.nRecNo = 1
This.Refresh()
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform