Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DoScroll
Message
From
26/03/2004 02:13:35
Walter Meester
HoogkarspelNetherlands
 
 
To
25/03/2004 16:10:17
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00889667
Message ID:
00889863
Views:
27
Hi Marcia,

I stepped away for using Setfocus() for a long time now because it might trigger all kinds of events depending on what object currently has the focus and might cause an error if a when or valid is in the call stack.

maybe a better approach is to ensure that the active row is at the top with something like:
	nHeight=THIS.Height
	THIS.Height=THIS.HeaderHeight+THIS.RowHeight
	
	DODEFAULT()
	THIS.Height=nHeight
in the refresh of the grid and use something like:
	FOR nT = 1 TO 5
		THIS.Doscroll(0)
	ENDFOR
to scroll up.

Walter,






>I usually leave the pointer at the bottom of the table. When a user tabs to the Grid, which is usually on a different page, he sees the last record at the top of the grid.
>It would be nicer if he saw for instance the last 10 records, (with the last record hilighted).

>
>The follow code from chapter 6 of 1001 Things You Wanted to Know About Visual FoxPro leaves the record pointer on the last record in the grid.
>
>It is called from the form's init():
>
>
>*** Display the last page of the grid when the form instantiates
>IF DODEFAULT()
>  WITH Thisform.GrdCustomer
>    *** Calculate the maximum number of rows per grid page
>    lnMaxRows = INT( ( .Height - .HeaderHeight - ;
>    		     IIF( INLIST( .ScrollBars, 1, 3 ), SYSMETRIC( 8 ), 0 ) ) / .RowHeight )
>    GO BOTTOM IN ( .RecordSource )
>    lnRecNo = RECNO( .RecordSource )
>    *** Go to the record that should be in the first row of the last page
>    SKIP -( lnMaxRows - 1 ) IN ( .RecordSource )	
>    .SetFocus()
>    IF .RelativeRow < 1
>      *** Make sure it is the first relative row
>      DO WHILE .RelativeRow # 1
>        .DoScroll( 0 )
>      ENDDO	
>    ELSE
>      DO WHILE .RelativeRow # 1
>        .DoScroll( 1 )
>      ENDDO
>    ENDIF
>    *!* Now go back to the last record in the grid
>    GO lnRecNo IN ( .RecordSource )
>    .SetFocus()
>  ENDWITH
>ENDIF
>
>
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform