General information
Category:
Coding, syntax & commands
If I understand you correctly, you are adding records to a table and want to be sure that the last (bottom?) record displays in the grid?
I use a Grid class that does just that.
Two Grid properties are:
nRelRow = 0 && used to position last row of the table at the bottom of the grid
nRows = 0 && number of rows displayed in grid
The refresh method of the grid:
PROCEDURE Refresh
** position grid so that last row is displayed
lScreenWasLocked = THisForm.LockScreen
ThisFOrm.LockScreen = .T.
SELECT ( This.RecordSource )
WITH This
nRecs = RECCOUNT()
GO TOP
IF nRecs > 0
IF nRecs <= .nRows
GO Bottom && they all fit
ELSE
GOTO nRecs - .nRows + 1 && top record to display in grid
x = 2
DO WHILE x > 1 && scroll down until relative row is 1
.DoScroll( 1 )
.SetFocus
.Columns[1].Text1.GotFocus
x = .nRelRow
ENDDO
ENDIF
ENDIF
EndWith
ThisFOrm.LockScreen = lScreenWasLocked
EndProc && Refresh
ENDDEFINE && ledgerGrid
In the GotFocus of the textbox:
PROCEDURE GotFocus
This.Parent.Parent.nRelRow = This.Parent.Parent.RelativeRow
ENDPROC
HTH...someone else passed it on to me.
J
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only