Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I am getting crazy with filling grids dynamically
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00854780
Message ID:
00854868
Vues:
24
>For most of my grids (vfp8), I am using the following method:
>a) I do a select... into cursor cur_table
>b) I fill my grid with
>WITH THISFORM.wsgrid1
> .Columncount = 8
> .RecordSource = "cur_inv"
> .Column8.AddObject("wscheckbox1", "wscheckbox")
> .Column8.CurrentControl = "wscheckbox1"
> .Column1.ControlSource = "cur_inv.invno"
>... and so on
>
>It works perfectly when it is just a grid to select or view the records but I have a problem if the grid is used for data input:
>
>a) the valid code is not firing
>b) If I put a checkbox there before filling the grid and I don't add a new object, I loose my checkbox
>
>? Is there any way to define the objects within the grid and to not loose them (but still changing my controlsources)
>? Is there any way to add code on the interactive change method of the added wscheckbox1 after my addobject command
>
>thanks for any help
>Eric

I find it a lot easier to have the recordsource in place before the grid is initiated (ie. create the cursor in form.load or your data environment object etc.) and have the grid designed at runtime.

When you need to change the recordsource of the grid (assuming the same grid layout), simply :

thisform.mygrid.recordsource = ""

SELECT * ;
FROM mytable ;
WHERE mycondition ;
INTO mycursor READWRITE

thisform.mygrid.recordsource = "mycursor"

That will keep all formatting, methods etc. in the grid.
Cheers,
Jamie
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform