Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Editing an array with a grid
Message
From
09/09/1998 14:30:19
 
 
To
09/09/1998 14:24:37
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00134672
Message ID:
00134700
Views:
17
>>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform