When I use the RecNo property it gives an array error.
See Grid demo 25, with only the line below changed.
Code: Select all
Form_1.Grid_1.CellNavigation := .F.
Moderator: Rathinagiri
Code: Select all
Form_1.Grid_1.CellNavigation := .F.
Hello,trmpluym wrote: ↑Tue Jan 16, 2018 8:39 pm Using a Grid with a DBF as source with CellNavigation:=.F. , how can i get the recno() ?
When I use the RecNo property it gives an array error.
See Grid demo 25, with only the line below changed.
Code: Select all
Form_1.Grid_1.CellNavigation := .F.
Code: Select all
************************************************
function SetDataGridRecNo ( index , nRecNo )
************************************************
Local cRecordSource
Local aValue
Local nLogicalPos := 0
Local lOk := .f.
Local nBackRecNo
LOCAL nColumn := 0
cRecordSource := _HMG_SYSDATA [ 40 ] [ index ] [ 10 ]
nBackRecNo := &cRecordSource->( RECNO() )
aValue := _GetValue ( , , index )
if ValType (aValue) == 'A'
nColumn := aValue[2]
endif
if _IS_ACTIVE_FILTER_
lOk := .f.
nLogicalPos := 1
&cRecordSource->( DBGOTOP() )
Do While .Not. EOF()
If &cRecordSource->( RECNO() ) == nRecNo
lOk := .t.
// nNewRecNo := &cRecordSource->( RECNO() ) // ADD, march 2017
Exit
EndIf
&cRecordSource->( DBSKIP() )
nLogicalPos++
EndDo
else
lOk := .t.
&cRecordSource->( DBGOTO ( nRecNo ) )
nLogicalPos := &cRecordSource->( ORDKEYNO () )
// nNewRecNo := &cRecordSource->( RECNO() ) // ADD, march 2017
endif
If lOk
// &cRecordSource->( DBGOTO( nNewRecNo ) ) // ADD, march 2017
else
&cRecordSource->( DBGOTO( nBackRecNo ) )
endif
If lOk
_SetValue ( , , if (ValType (aValue) == 'A', { nLogicalPos , nColumn } , nLogicalPos) , index )
EndIf
return nil
*************************************
function GetDataGridRecno( index )
*************************************
Local cRecordSource := ''
Local nHandle
Local aColumnFields := {}
Local lRet := .T.
Local aValue
Local nValue
Local nRecNo
Local nBackRecNo
Local aTemp
Local nBuffLogicalRow
Local nBuffPhysicalRow
Local k
nHandle := _HMG_SYSDATA [ 3 ] [ index ]
aColumnFields := _HMG_SYSDATA [ 40 ] [ index ] [ 11 ]
cRecordSource := _HMG_SYSDATA [ 40 ] [ index ] [ 10 ]
nBackRecNo := &cRecordSource->( RECNO() )
aValue := _GetValue ( , , index )
nValue := if ( ValType (aValue) == 'A', aValue[1], aValue )
if _IS_ACTIVE_FILTER_
&cRecordSource->( DBGOTOP() )
&cRecordSource->( DBSKIP( nValue - 1 ) )
else
&cRecordSource->( ORDKEYGOTO ( nValue ) )
endif
If &cRecordSource->(EOF())
nRecNo := 0
// Try to get the buffer record number (if available)
aTemp := _HMG_SYSDATA [ 40 ] [ index ] [21]
For k := 1 To HMG_LEN ( aTemp )
// Get Buffer Data
nBuffLogicalRow := aTemp [ k ] [ 1 ]
nBuffPhysicalRow := aTemp [ k ] [ 4 ]
If nBuffLogicalRow == _HMG_SYSDATA [ 39 ] [ index ]
nRecNo := nBuffPhysicalRow
Exit
EndIf
Next
Else
nRecNo := &cRecordSource->( RECNO() )
EndIf
&cRecordSource->( DBGOTO( nBackRecNo ) )
return nRecNo