Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting Grid RECORDSOURCE vs Grid Builder
Message
De
17/01/2000 08:56:21
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
16/01/2000 19:54:51
Gavin Reid
L & M Marketing Pty Ltd
Frenchs Forest, Australie
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00318814
Message ID:
00318917
Vues:
32
>Hi All,
>
> I just wanted to share an experience that I've recently had concerning Grids and the RECORDSOURCE property. I constructed a Table Maintenance Form which had 2 Tab Pages. The first Tab Page has a Grid of all the records in the table and the second Tab Page has the fields from the current record. I have a Property called MaintAlias in the Formset which holds the name of the Table that is to be maintained and I use this Property to set the RECORDSOURCE for the Grid in the ACTIVATE Event of the Formset. I used the Grid Builder to arrange the fields in a specific order. After I ran the form I noticed that the Grid headers didn't match up to the data in the
>corresponding Grid fields, one field had even split over two Grid columns. I checked the Table to make sure that I'd entered data in the correct fields, and it was fine. I couldn't figure out what was happening. I then commented out the code that set the RECORDSOURCE and the Grid worked fine.
>
> Has anyone else encountered this problem? It seems that VFP6.0 doesn't like a Grid being built with a Builder and then having the RECORDSOURCE specified when the Form is invoked.
>
> Is it a bug or am I just doing it the wrong way?
>
>Gavin...


Gavin,
If you want to change recordsource in code first decide if you want to preserve column formatting or not.
-If you are gonna preserve formatting :
Grid.Recordsource = "" && Set it to nothing first
* Do whatever you would do with source
Grid.Recordsource = "myTableOrCursor" && Set recordsource

If you do it directly then you get weird results.

-If you won't preserve formatting
Grid.Recordsource = "" && Set it to nothing first
Grid.ColumnCount = -1 && Reset all columns
Grid.Recordsource = "myTableOrCursor" && Set recordsource

Headers wouldn't match the table naturally because a grid binds its columns with field order if not specified in code. I suggest if you're changing recordsource and columns do not match field order :
-Either first save current columns.controlsources to array before blanking recordsource and reassign using array info.
-Or set column.controlsources in code.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform