Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Refreshing a Grid, populated by a query
Message
De
19/03/2002 14:27:33
Adam Skowronski
Custom Designed Systems
Miami, Floride, États-Unis
 
 
À
28/02/2002 07:46:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00626188
Message ID:
00634608
Vues:
21
Hi Marcia,

Excuse me for being slow here, but I'm not accustomed to populating grids with updatable data, just for display. I'm having trouble following your suggestion below. If I read it right, I would first have to create the cursor (gstOrders) to populate the grid before it is displayed in the Load.event of the form. Then
after changing/adding a record, run the RefreshGrid method to repopulate the grid with the changes.

When running the form, I get variables not found, unbinding opjects, where the data is in the cursor gstOrders. You see, I have text controls also on the form for editing the current record in the grid, and that's where the errors are coming from. Any further ideas would be helpful.

TIA
Adam


>Hi Adam.
>
>I have a data add/edit/delete form with a grid whose control source is a query, and the query is pulling data from four tables. When I add, edit or delete a record via the form, the data in the associated tables gets updated properly, but the grid upon refresh() ends up a blank white space. Can someone give me some ideas on what to do to get the grid to refresh properly after the query is refreshed...
>
>The cleanest solution here is to set up a parameterized view and Requery the view when you need to refresh the contents of the grid. If, for some reason, this is not convenient, even though Vlad's solution work, you lost all of your column widths and controlSources because the grid gets rebuildt from scratch when you use this technique.
>
>If you must use a cursor, a better technique is what I like to call a "safe select". What you need to do is:
>
>

    >
  1. Create the cursor to use as the grid's RecordSource in the Form.Load using CREATE CURSOR

  2. >
  3. Add a method called ResetGrid to either your form or your grid class

  4. >
  5. Call The ResetGrid method whenever you need to refresh the grid

  6. >

>
>This is the code that goes in the ResetGrod mthod:
>
>*** Rebuild the cursor used as the recordSource for the grid
>SELECT ( This.RecordSource )
>ZAP
>SELECT * FROM MyTable WHERE SomeCondition INTO CURSOR Temp NOFILTER
>SELECT ( This.RecordSource )
>APPEND FROM DBF( 'Temp' )
>USE IN Temp
>GO TOP IN ( This.RecordSource )
>
>
>Zapping the grid's RecordSource does not close it. This technique also has the advantage of keeping all of the grid's formatting and ControlSources when it is refreshed.
Adam J Skowronski
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform