Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example creates a workbook with five sheets. In the BeforeEditMode event, if the cell going into edit mode is in column 1 of sheet 3, the edit mode change is canceled.

C++

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

void CAboutDlg::OnBeforeEditModefPSpread1(long Col, long Row, long UserAction, VARIANT FAR* CursorPos, VARIANT FAR* Cancel)
{
    // Prevent data from being typed in column 1, sheet 3
    if (m_Spread.GetSheetSendingEvent() == 3 && Col == 1)
    {
        Cancel->boolVal = VARIANT_TRUE;
    }
}

Visual Basic

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

Private Sub fpSpread1_BeforeEditMode(ByVal Col As Long, ByVal Row As Long, ByVal UserAction As FPSpread.BeforeEditModeActionConstants, CursorPos As Variant, Cancel As Variant)
    ' Prevent data from being typed in column 1, sheet 3
    ' Get the sheet that is sending the event
    If (fpSpread1.SheetSendingEvent = 3 And Col = 1) Then
        Cancel = True
    End If
End Sub

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.