CGXBrowserGrid::MoveTo
virtual BOOL MoveTo(ROWCOL nRow);
nRow
Specifies the row id.
Return Value
Nonzero if successful; otherwise 0.
Remarks
Called to position the recordset to the given row. You should return FALSE if the positioning failed. See the attached example.
One reason the positioning could fail and that you should return FALSE is if nRow is larger than the record count.
Example
This sample demonstrates how MoveTo positions the current record by calling SetAbsolutePosition for a CDaoRecordset. If the positioning fails, the method returns FALSE.
BOOL CGXDaoGrid::MoveTo(ROWCOL nRow)
{
CGXBrowseParam* pBrowseData = GetBrowseParam();
if (m_pRecordset == NULL || !m_pRecordset->IsOpen() ||
(long) (nRow-GetHeaderRows()) > OnGetRecordCount())
return FALSE;
long nRecord = GetRecordFromRow(nRow);
long nCurrentRecord = m_pRecordset->GetAbsolutePosition();
if (nCurrentRecord == nRecord)
return TRUE;
try
{
if (abs(nCurrentRecord-nRecord) > pBrowseData->m_lMoveRecordWaitCursor)
{
// display wait cursor
CGXWaitCursor theWait;
m_pRecordset->SetAbsolutePosition(nRecord);
}
else
m_pRecordset->SetAbsolutePosition(nRecord);
}
catch (CDaoException* e)
{
e->Delete();
return FALSE;
}
if (m_pRecordset->IsEOF())
{
pBrowseData->m_bEOFSeen = TRUE;
return FALSE;
}
return TRUE;
}