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

Grids and TextBoxs - Refreshing

Status
Not open for further replies.

AlastairOz

Technical User
Jul 27, 2010
81
AU
I have a form with a grid
I also have various text boxes on the form.
When I move up and down in the grid I see the record pointer
moving in the table to the same position as the grid.
The text boxes only display the correct record wheb I click the grid row. Other wise when moving up and down the grid with the arrow keys, the text boxes display the previous record.
I refreshed the form in the grid's BeforeRowchange, AfterRowChange, KeyPress, Click events.
What am I doing wrong?
 
That's normal behaviour.

There's one active row, scrolling through a grid does not change this. BeforeRowChange, AfterRowchange events happen, when you change the active record, not when you scroll.

Bye, Olaf.
 
Hi Olaf,
I am not scrolling with the scroll bars.

I click on a row in the grid.
I get the correct details in the text boxes
I then move up or down in the grid with the arrow keys.
I have the table open also.
I see the record pointer moving in the table, to the correct record.
The text boxes update, but not the correct record,
the previous record.
There has to be some way of getting the text boxes to sync up.
Regards
Alastair
 
I see. The only right event to update the textboxes via refresh is the Afterrowcolchange(), that's where you could end up in a new row. Thisform.refresh() should refresh all.

Bye, Olaf.
 
Alastair,

The way you described it, it should work. If you have THISFORM.Refresh in the grid's AfterRowColChange, you should see the text boxes staying in sync with the grid.

If that's not what's happening, check your code. Try putting a MESSAGEBOX() in the AfterRowColChange to check that the event is in fact being triggered.

Also, check that the text boxes' controlsources are all set correctly.

Off-hand, I can't think of any other reason why it shouldn't work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Controlsources should of course be set to the same alias as the grid. Maybe a refresh in all the events is a problem, so remove all refresh code from all the other events.

one of the two before/afterrowcolchange don't happen when you move focus away from the grid or to the grid. Anyway changing the record through any other control, eg a skip in a "next" navbar button should also call a refresh.

Take a look into the solution samples with navbars and grids, there are several in controls->grids and more.

This is something you forget about quite soon when using a framework that does all this in it's base classes already. It's a good idea to create a grid class having such behavior in it's events and use that instead of a native grid all the time, then you don't have to think about it again.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top