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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh does not update grid

Status
Not open for further replies.

andre65

Programmer
Jan 19, 2003
95
NL
I have a Form with a Grid.
In the Form I've created
- a property p_cOrderBy
- a method m_load() which creates a cursor named cr_data ordered by p_cOrderBy and does thisform.refresh(). Because I use VFP 6.0 I first create cursor cr_data in Form.load(). In Form.m_load() I zap cr_data, select the data in an array and use APPEND FROM ARRAY.

The Grid's recordSource is cursor cr_data.
The Form.init calls m_load(), so the Grid is populated by cr_data.

In de Grid.Columns(x).Header1.click event I put the code:
thisform.p_cOrderBy = [fieldname]
thisform.m_load()

Now, when running the form, initially i see the data in the Grid. But when clicking a Header, the Grid displays nothing, while the cursor cr_data contains the new ordered content.

Why is does and what should I do to see the new data .
 
Andre65,

I suspect that the grid has scrolled to the very end of the table. The data is all there in the grid, but you need to scroll up in order to see it. Try doing that manually, and if it works, you can do it programmatically by calling the grid's Doscroll method.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Andre65,

You don't mention setting the grid's RecordSource before running m_load. When you re-create the data to which a grid is bound, you need to set the grid's RecordSource to an empty string before. So I think if the header click method had this:

thisform.p_cOrderBy = [fieldname]
Grid.RecordSource = []
thisform.m_load()
Grid.RecordSource = [cr_data]

Another thing I do when refreshing grids is to use the form's LockScreen property. Setting this to .T. prevents the form from trying to repaint itself, which is slow. So if you set it to .T. before the 4 lines above and then set it to .F. after the 4 lines, you will probably get a cleaner result.


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
MikeLewis:
The Grid is an empty Grid, cannot scroll (in fact, after APPEND FROM ARRAY I do GO TOP)

Stewart:
Your suggestion works fine. In addition I have to set the Grid.Columns(x).ControlSource property again because after Grid.RecordSource=[] these setting are gone.

Mike and Stewart, thanks for your reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top