Spread Windows Forms 6.0 Product Documentation
SwapRange Method
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SheetView Class : SwapRange Method


fromRow
Row index of the top-left cell in the block from which to swap
fromColumn
Column index of the top-left cell in the block from which to swap
toRow
Row index of the top-left cell in the destination block
toColumn
Column index of the top-left cell in the destination block
rowCount
Number of rows in the block of cells
columnCount
Number of columns in the block of cells
dataOnly
Whether only the data is copied, or the data and formatting

Glossary Item Box

Swaps the data and formatting in a block of cells on this sheet with another block of cells on this sheet.

Syntax

Visual Basic (Declaration) 
Public Sub SwapRange( _
   ByVal fromRow As Integer, _
   ByVal fromColumn As Integer, _
   ByVal toRow As Integer, _
   ByVal toColumn As Integer, _
   ByVal rowCount As Integer, _
   ByVal columnCount As Integer, _
   ByVal dataOnly As Boolean _
) 
Visual Basic (Usage)Copy Code
Dim instance As SheetView
Dim fromRow As Integer
Dim fromColumn As Integer
Dim toRow As Integer
Dim toColumn As Integer
Dim rowCount As Integer
Dim columnCount As Integer
Dim dataOnly As Boolean
 
instance.SwapRange(fromRow, fromColumn, toRow, toColumn, rowCount, columnCount, dataOnly)
C# 
public void SwapRange( 
   int fromRow,
   int fromColumn,
   int toRow,
   int toColumn,
   int rowCount,
   int columnCount,
   bool dataOnly
)

Parameters

fromRow
Row index of the top-left cell in the block from which to swap
fromColumn
Column index of the top-left cell in the block from which to swap
toRow
Row index of the top-left cell in the destination block
toColumn
Column index of the top-left cell in the destination block
rowCount
Number of rows in the block of cells
columnCount
Number of columns in the block of cells
dataOnly
Whether only the data is copied, or the data and formatting

Exceptions

ExceptionDescription
System.InvalidOperationException Operation is not valid; cannot swap entire sheet of cells
System.InvalidOperationException Operation is not valid; cannot swap entire columns over partial columns
System.InvalidOperationException Operation is not valid; cannot swap entire rows over partial rows
System.InvalidOperationException Operation is not valid; cannot swap a range of cells over part of a spanned cell

Example

This example swaps the data between two ranges of cells.
C#Copy Code
int i, j;
fpSpread1.ActiveSheet.RowCount = 10;
fpSpread1.ActiveSheet.ColumnCount = 10;
for (i = 0; i <= 9; i ++)
{ 
    for (j = 0; j <= 9; j++)
    {
        fpSpread1.ActiveSheet.SetValue(i, j, i + 1);
    }
}
fpSpread1.ActiveSheet.SwapRange(0, 0, 3, 0, 3, 3, true);
}
Visual BasicCopy Code
Dim i, j As Integer
FpSpread1.ActiveSheet.RowCount = 10
FpSpread1.ActiveSheet.ColumnCount = 10
For i = 0 To 9
    For j = 0 To 9
        FpSpread1.ActiveSheet.SetValue(i, j, i + 1)
    Next j
Next i
FpSpread1.ActiveSheet.SwapRange(0, 0, 3, 0, 3, 3, True)

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

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