Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best Practice on Refresh Grid with Data
Message
De
12/07/2020 16:03:46
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., Nouvelle Zélande
 
 
À
10/07/2020 07:34:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
01675136
Message ID:
01675143
Vues:
87
>>In our big and Old VFP9 Application we Read data from SQL Server via SQLExec(), and show the Data in VFP – Grid.
>>Sometimes we have to Reload the Data and since Years this is done in this sequence:
>>- Reload the Data (sqlexec() ) into the same named Cursor as before.
>>- Remove the Grid (oGrid.release() )
>>- Create an New Grid Instance (newobject() )
>>And, also since years, we fight against C5 Errors…

Traditional answer would be that Remote Views avoid this issue altogether- but they're not always practical/flexible enough.

Theoretically you can set recordsource to "" before recreating the source cursor and the grid's layout should survive, but many of us have experienced blankings or other unstable symptoms from the event sequence or other unanticipated consequences- especially if focus is in the grid when this happens.

Which is why I'd strongly support Tore's advice wrt safe select, especially if you have complicated grids with careful widths and dynamic... settings. I did not know it was called "safe select" (learned something!) but this technique is widely used in our apps without C5 errors or infuriating visual anomalies.

Safe Select also makes it very easy to (for example) re-order by clicking header columns etc by simply adding an ORDER BY to the select. It's generic enough that you can create Resequence() and similar methods in your grid class and not have to look at it again for years at a time.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform