Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LOSING GRID PEMS
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00042759
Message ID:
00042771
Vues:
32
>When I run another select statement on the alias that is my grid's RecordSource, I lose all of the PEMs of the grid. I have tried thisform.myGrid.RecordSource = "" before running the Select statement, then resetting to the RecordSource after, but I lose the columns controlsource. Do I have to save and restore all of the columns PEMs also? What a pain!

Here's an extract of code we use to preserve grid settings during requeries. Setting the recordsource to blank like some people say does not work. What we do is create 2 identical cursors at first, in this case DGender and QGender. The recordsource of the grid is set to QGender when the form loads. When its time to requery QGender, we store the control sources, set the recordsource to DGender, requery QGender, reset the recordsource to QGender, and then reset the control sources.

This is the only way we've been able to make this work. So long as QGender's structure always matches DGender's this will do it.

***********************************************************
* Variables to hold ControlSource values
LOCAL lcCensCodeControlSource,;
lcCensTitleControlSource,;
lcFemaleControlSource,;
lcMaleControlSource,;
lcYearControlSource

* Save ControlSource properties to variables
WITH THISFORM.grdDemGender
lcPeriodControlSource = .grcPeriod.ControlSource
lcCensCodeControlSource =.grcCensCode.ControlSource
lcCensTitleControlSource = .grcCensTitle.ControlSource
lcFemaleControlSource = .grcFemale.ControlSource
lcMaleControlSource = .grcMale.ControlSource
lcYearControlSource = .grcYear.ControlSource
ENDWITH

* Set RecordSource to DGender to preserve column settings
THISFORM.grdDemGender.RecordSource = "DGender"

* Requery
Your SELECT here
INTO CURSOR QGender

* Reset RecordSource to QGender
THISFORM.grdDemGender.RecordSource = "QGender"

* Set RecordSource to itself per Microsoft Knowledge Base. Don't ask me
why you have to do this but if you don't this doesn't work.
THISFORM.grdDemGender.RecordSource = THISFORM.grdDemGender.RecordSource

* Reset ControlSource properties from variables
WITH THISFORM.grdDemGender
.grcPeriod.ControlSource = lcPeriodControlSource
.grcCensCode.ControlSource = lcCensCodeControlSource
.grcCensTitle.ControlSource = lcCensTitleControlSource
.grcFemale.ControlSource = lcFemaleControlSource
.grcMale.ControlSource = lcMaleControlSource
.grcYear.ControlSource = lcYearControlSource
ENDWITH

* Refresh grid
THISFORM.grdDemGender.Refresh
***********************************************************

HTH, and comments from other folks on streamlining this would be greatly
appreciated!
"It is an important and popular fact that things are not always what they seem. For instance, on the planet Earth, man had always assumed that he was more intelligent than dolphins because he had achieved so much -- the wheel, New York, wars and so on -- whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man -- for precisely the same reasons." - Douglas Adams
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform