Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example creates a workbook with three sheets. When the user changes the active sheet, the SheetChanged event occurs, and the old and new sheet indices are displayed.

C++

#include "tchar.h"

BOOL CAboutDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    // Set number of sheets
    m_Spread.SetSheetCount(3);
}

void CAboutDlg::OnSheetChangedFpSpread1(short OldSheet, short NewSheet)
{
    CString buffero;
    CString buffern;
    CString message;

    // Convert variables to show in message box
    buffero.Format(_T("%x"), OldSheet);
    buffern.Format(_T("%x"), NewSheet);
    message =_T("Old ") + buffero + _T(" New ") + buffern;
    ::MessageBox(NULL, (LPCTSTR)message, "message body", MB_OK);
}

Visual Basic

Private Sub Form_Load()
    ' Set number of sheets
    fpSpread1.SheetCount = 3
End Sub

Private Sub fpSpread1_SheetChanged(ByVal OldSheet As Integer, ByVal NewSheet As Integer)
    ' Show old and new sheet numbers in immediate window
    Debug.Print OldSheet, NewSheet
End Sub

Copyright © GrapeCity, inc. All rights reserved.