Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Disappearing Grid Method
Message
De
13/03/2006 10:25:23
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01103672
Message ID:
01103733
Vues:
19
This message has been marked as the solution to the initial question of the thread.
I am stumped at the loss of my right-click method when changing the record source for a grid contained within a pageframe. When I initially open the form, the grid on page 3 shows the proper table that I have chosen and the right click method performs as I have coded. If I programmatically change the record source, the right click method no longer performs as it should. It appears as if the method no longer fires at all. Is there an explanation for this?

My advicew to you is to use a "Safe Select" nstead on setting the grid's RecordSource to an empty string.

See Andy's Blog entry for an explanation at http://weblogs.foxite.com/andykramek/archive/2005/03/19/174.aspx.

This is what I had to say on the subject in Chapter 6 of 1001 Things You Wanted to Know About Visual FoxPro:

The RecordSource of the categories grid is an updateable cursor. This cursor, csrCategory, is defined in the form's Load method using the CREATE CURSOR command. The cursor is populated in the grid's Reset method by ZAPping csrCategory, SELECTing the appropriate records into a temporary cursor and then appending the records from the temporary cursor into csrCategory. Reset is a custom method we added to our grid class to consistently populate or re-populate all grids using a common method. Here is the code from the categories grid's Reset method:
SELECT csrCategory
ZAP
SELECT * FROM Categories ;
   WHERE Categories.Cat_No = This.Parent.cboSections.Value ;
     INTO CURSOR Temp NOFILTER
SELECT csrCategory
APPEND FROM DBF( 'Temp' )
USE IN Temp
GO TOP IN csrCategory
This.nRecNo = 1
This.Refresh()
There are a few reasons for doing it like this. First, we can set the categories grid up visually in the form designer since its RecordSource exists prior to instantiation. More important is the fact that a grid does not like having its RecordSource ripped out from under it. If the grid's RecordSource were updated by SELECTing into it directly, it would appear as a blank grey blob on the screen. This is because the SELECT closes the cursor and effectively leaves the grid hanging in mid air, so to speak. ZAPping it, on the other hand, does not.

One way to avoid having the grid turn into a blank grey blob is to set its RecordSource to an empty string before running the SELECT and then resetting it afterward. Although this will work in the simplest of cases, it is not a solution we 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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform