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

moving between grid pages

Status
Not open for further replies.

arielap

Technical User
Aug 2, 2003
71
GB
This app includes a form with a pageframe with three overlapping pages, each with a grid displaying up to 9 columns.
Pressing pgUp / PgDn displays the previous or next page - as expected, but there are two problems

1 Moving foward from P1 to P2 or P2 to P3 - the record pointer stays on the same record, as intended, but there's nothing to show where the user is until they press Enter, when the record highlight duly appears. I've tried 'keyboard Enter' in AfterRowVColChange without success.
How can I show the active row without the user needing to press Enter?


2. Returning from P3 to P2 or P2 to P1 doesn't stay on the record in use but moves to the top record displayed .
The code that should move back a page and stay on the same record is in the form's keypress -:

Code:
if nKeyCode=18  && pgup
   gplace=RECNO()
   if this.pageframe1.activepage=3
      this.pageframe1.activepage=2
      GOTO gplace  
      ThisForm.Pageframe1.Page2.grdPage2.Column2.txtplates.SetFocus
      ThisForm.Pageframe1.Page2.grdPage2.Refresh
   else
      if this.pageframe1.activepage=2
         this.pageframe1.activepage=1
         GOTO gplace
         ThisForm.Pageframe1.Page1.grdPage1.Column2.txtClass1.SetFocus
         ThisForm.Pageframe1.Page1.grdPage1.Refresh
      endif
   ENDIF
   thisform.refresh()
endif
How can I keep the record pointer on the same record when paging backwards?

 
Arielap,

Re your first question, it should be enough to do a SetFocus on the grid. You could do that in the page's Activate, perhaps.

I can't see why the pointer moves to the top of the grid when you go to the previous page -- unless it's because a different alias is selected. Are there any other tables open at this point (in the same data session)? If so, I'd pass the alias of the table you are navigating to the RECNO() function.

Also, are you sure you need to refresh the grid each time, as well as the form? That's not directly related to your problem, but it will have an effect on performance.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike,
I tried Setfocus to the grid in the page's activate - and it highlit a record OK, - but it was the one on the bottom of the page.

At which point I realised why the record position was changing. Using the paging cursors didn't just do what I'd program them to do but also moved the record pointer to page bottom before that.

Changing pages by clicking on the page tab works as planned but this is a keyboard data entry/edit module and using cursor keys to change pages is the users' natural and preferred action.

So the question now is - how can I make the cursor keys replicate the pagetab's mouse click /Alt n actions?


 
Ah, yes. I think I can see what's happening. You are trapping PgUp and PgDn in the grid's Keypress. But, in addition to changing pages, the keystrokes' default behaviour is also kicking in. That's why the record pointer is moving.

If I'm right about the that, the solution is to execute NODEFAULT in the Keypress.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
>> the keystrokes' default behaviour is also kicking in.
exactly so.

>> the solution is to execute NODEFAULT in the Keypress.
And it was :)

I Put the nodefault immediately after the
if nKeyCode=nnn
line for the paging key and the keys worked as intended (by me)

tho' if I put it at the end of the relevant ENDIF (whichj I tried first) none of the keys worked.

very many thanks -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top