Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid resizing columns when repopulated

Status
Not open for further replies.

Steve60007

Technical User
Dec 27, 2012
3
US
Building an app in VFP after not using it for years I'm surprised it's coming along so
well, but I ran into probably really simple a little problem:

I'm repopulating a cursor and then a grid based on pageframe selection, initially the grid
sizes everything correctly (from the grid's init event), but as soon as a page is chosen it shrinks all the columns down to
the longest field of data in that column.

I tried specifying each column width both after the select statement (throws an error because it
doesnt exist yet), and after the recordsource (didn't do anything)

SELECT name, address, amount,cc, status FROM orders WHERE status = "In Store" INTO CURSOR activord
thisform.grid1.RecordSourceType=1
thisform.grid1.RecordSource = [activord]

I initially populate the grid from the grid's init event, then from each pages activate event. I already tried
recalling the init event with each page and changed select statement, but it didn't work.

Any idea how I can keep the initial column formatting after page changes?


 
nevermind i figured it out, just needed to refresh again after specifying the column widths
 
There is a better way to let the grid not forget it's column properties, widths etc than to restore them:

1. create a cursor from the data to be displayed
2. in case of updating grid data by a requery of that cursor, don't do that, but query into a secondary cursor, zap the grid cursor and append the new data to it

Instead of that what also is applicable is views, as their inner working is about the same way, when you REQUERY(), they just get repopulated, they don't get recreated.

Bye, Olaf.
 
Thanks Olaf,

It's currently working good with the refresh, but I think your advice will
make things much easier as I add functionality and have to update the tables.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top