Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Editing an array with a grid
Message
De
09/09/1998 14:30:19
 
 
À
09/09/1998 14:24:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00134672
Message ID:
00134700
Vues:
16
>>>OK, so may be this is old news, but I worked it out only recently. It happens that you can edit data in an array using a grid, and the steps are like follows:
>>>
>>>1. In the FORM.LOAD event, load your array. You can either use a PUBLIC array (not very good programming practice) or define an array property for the FORM (better).
>>>
>>>2. In the same event, CREATE a cursor with only one field and a record for each row in your array.
>>>
>>>CREATE CURSOR FICTITIOUS (XXX N(1))
>>>FOR I=1 TO ALEN(yourarray,1)
>>> APPEND BLANK
>>>ENDFOR
>>>
>>>3. In the GRID init event, set the RecordSource to the cursor you created, and set each COLUMNSOURCE to point to the array like this:
>>>
>>>FOR J=1 TO ALEN(yourarray,2)
>>> cJ = STR(J)
>>> THIS.COLUMNS(J).CONTROLSOURCE = "yourarray[RECNO(),&cJ]"
>>>ENDFOR
>>>
>>>You are done! (Why the cursor? Because every grid must have a record source, and you can use the RECNO() of the cursor as a "row pointer".)
>>>
>>>Any opinions, suggestions, criticisms, flames?
>>
>>[...] If you bind column.controlsource to array element then (I guess) you should see the same values in all rows of the same column.
>
>No, using RECNO() as the row number in the ControlSource fixes that. In effect, each element in a column has a different ControlSource.

Ok, but you omitted the first part of my reply, which, IMO, is more important. Anyway, you need in cursor of the same size as array, so just throw out the array as redundant element and it still works the same way.
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform