Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Editing an array with a grid
Message
From
09/09/1998 14:13:46
 
 
To
09/09/1998 14:05:53
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00134672
Message ID:
00134682
Views:
10
>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?

IMO, more natural way is to use whole cursor as grid base and just populate array from this cursor (if really necessary) when whole process gets finished or even from each column.control lostfocus/valid events. If you bind column.controlsource to array element then (i guess) you should see the same values in all rows of the same column.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform