Example
The following example sets the active cell to be cell C25. The user can press one command button to view the top-left cell in the sheet, and another to view the active cell.
C++
void CTestDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// Set text for buttons and set the active cell
m_Command1.SetWindowText("View Active Cell");
m_Command2.SetWindowText("View Top-Left Cell");
m_Spread1.SetActiveCell(3, 25);
}
void CTestDlg::OnButton1()
{
// View the active cell
m_Spread1.ShowCell(m_Spread1.GetActiveCol(), m_Spread1.GetActiveRow(), PositionCenter);
}
void CTestDlg::OnButton2()
{
// View the top-left cell
m_Spread1.ShowCell(1, 1, PositionUpperLeft);
}
Visual Basic
Private Sub Form_Load()
' Set text for buttons and set the active cell
Command1.Caption = "View Active Cell"
Command2.Caption = "View Top-Left Cell"
fpSpread1.SetActiveCell 3, 25
End Sub
Private Sub Command1_Click()
' View the active cell
fpSpread1.ShowCell fpSpread1.ActiveCol, fpSpread1.ActiveRow, PositionCenter
End Sub
Private Sub Command2_Click()
' View the top-left cell
fpSpread1.ShowCell 1, 1, PositionUpperLeft
End Sub