I'm working in VFP7 on sub-classing a grid to make it easier to dynamically assign a new table to grid's RecordSource without losing all of my column settings. I'm following the basic outline seen in several articles--some on this forum.
i.e.
I finally have all of the working pretty well. I'm still struggling with the initialization of the grid. But the real problem I'm having now is that the grid displays the same values for every record in the new table!
More specifically, the grid seems to display the number of rows corresponding to the number of records in the new table, but each of those rows contains values from the current record pointer in the table--generally record 1.
I hate grids...![[neutral] [neutral] [neutral]](/data/assets/smilies/neutral.gif)
A little debugging and I find that if I open the table separately (in the same datasession) while my grid is still visible, the grid will display the values associated with my current record in the table. I move to a new record and reactivate the grid, and voila! All the records display the new values. Pretty slick, huh? Not very useful though.
I don't think it has any bearing on the problem, but the column properties that I am saving and restoring are:
grid.columns[n].controlsource
grid.columns[n].width
grid.columns[n].header1.caption
Yes, I am going to the trouble of specifying the alias for the new table as I restore the controlsource properties. Refreshing the grid doesn't help.
Can anyone give me a hint at what I am missing? What could possibly cause the grid to display the same values for every record in the collection?
And why the heck is it so darn difficult to dynamically assign a table with the same structure to a grid. To be honest, I have never found the other RecordSourceTypes to be very useful either. I'm thinking of going back to BROWSE.
Thanks in advance for your help,
Ron
i.e.
Code:
Save your column properties somewhere
Set grid.RowSource = ""
cNewTablePath = <Path to the new table>
Set grid.RowSource = ["]+ cNewTablePath + ["] && This was a hummdinger!
Set grid.RowSourceType = 0 && Because it defaults to 1 if you don't. @#$%^&*!!!
Restore column properties from somewhere
I finally have all of the working pretty well. I'm still struggling with the initialization of the grid. But the real problem I'm having now is that the grid displays the same values for every record in the new table!
More specifically, the grid seems to display the number of rows corresponding to the number of records in the new table, but each of those rows contains values from the current record pointer in the table--generally record 1.
I hate grids...
![[neutral] [neutral] [neutral]](/data/assets/smilies/neutral.gif)
A little debugging and I find that if I open the table separately (in the same datasession) while my grid is still visible, the grid will display the values associated with my current record in the table. I move to a new record and reactivate the grid, and voila! All the records display the new values. Pretty slick, huh? Not very useful though.
I don't think it has any bearing on the problem, but the column properties that I am saving and restoring are:
grid.columns[n].controlsource
grid.columns[n].width
grid.columns[n].header1.caption
Yes, I am going to the trouble of specifying the alias for the new table as I restore the controlsource properties. Refreshing the grid doesn't help.
Can anyone give me a hint at what I am missing? What could possibly cause the grid to display the same values for every record in the collection?
And why the heck is it so darn difficult to dynamically assign a table with the same structure to a grid. To be honest, I have never found the other RecordSourceTypes to be very useful either. I'm thinking of going back to BROWSE.
Thanks in advance for your help,
Ron