Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example creates a form that lets users select columns or rows, and then copy, move, or swap the columns or rows within the sheet.

C++

void CTestprojDlg::OnButton1()
{
    // Copy selected columns
    m_Spread1.CopyColRange(m_Spread1.GetSelBlockCol(), m_Spread1.GetSelBlockCol2(), m_ColRowNum);
}

void CTestprojDlg::OnButton2()
{
    // Move selected columns
    m_Spread1.MoveColRange(m_Spread1.GetSelBlockCol(), m_Spread1.GetSelBlockCol2(), m_ColRowNum);
}

void CTestprojDlg::OnButton3()
{
    // Swap selected columns
    m_Spread1.SwapColRange(m_Spread1.GetSelBlockCol(), m_Spread1.GetSelBlockCol2(), m_ColRowNum);
}

void CTestprojDlg::OnButton4()
{
    // Copy selected rows
    m_Spread1.CopyRowRange(m_Spread1.GetSelBlockRow(), m_Spread1.GetSelBlockRow2(), m_ColRowNum);
}

void CTestprojDlg::OnButton5()
{
    // Move selected rows
    m_Spread1.MoveRowRange(m_Spread1.GetSelBlockRow(), m_Spread1.GetSelBlockRow2(), m_ColRowNum);
}

void CTestprojDlg::OnButton6()
{
    // Swap selected rows
    m_Spread1.SwapRowRange(m_Spread1.GetSelBlockRow(), m_Spread1.GetSelBlockRow2(), m_ColRowNum);
}

Visual Basic

Private Sub Command1_Click()
    ' Copy selected columns
    fpSpread1.CopyColRange fpSpread1.SelBlockCol, fpSpread1.SelBlockCol2, Text1.Text
End Sub

Private Sub Command2_Click()
    ' Move selected columns
    fpSpread1.MoveColRange fpSpread1.SelBlockCol, fpSpread1.SelBlockCol2, Text1.Text
End Sub

Private Sub Command3_Click()
    ' Swap selected columns
    fpSpread1.SwapColRange fpSpread1.SelBlockCol, fpSpread1.SelBlockCol2, Text1.Text
End Sub

Private Sub Command4_Click()
    ' Copy selected rows
    fpSpread1.CopyRowRange fpSpread1.SelBlockRow, fpSpread1.SelBlockRow2, Text1.Text
End Sub

Private Sub Command5_Click()
    ' Move selected rows
    fpSpread1.MoveRowRange fpSpread1.SelBlockRow, fpSpread1.SelBlockRow2, Text1.Text
End Sub

Private Sub Command6_Click()
    ' Swap selected rows
    fpSpread1.SwapRowRange fpSpread1.SelBlockRow, fpSpread1.SelBlockRow2, Text1.Text
End Sub

Private Sub Form_Load()
    ' Set up the copy, move, swap input
    Label1.Caption = "Select the columns or rows to copy, move, or swap."
    Label2.Caption = "Column or row at which to copy, move, or swap."
    Text1.Text = ""
    Command1.Caption = "Copy columns"
    Command2.Caption = "Move columns"
    Command3.Caption = "Swap columns"
    Command4.Caption = "Copy rows"
    Command5.Caption = "Move rows"
    Command6.Caption = "Swap rows"
End Sub

Copyright © GrapeCity, inc. All rights reserved.