Spread ASP.NET 6.0 Product Documentation
Swap Method
See Also  Example Send Feedback
FarPoint.Web.Spread Assembly > FarPoint.Web.Spread.Model Namespace > DefaultSheetDataModel Class : Swap Method


fromRow
Row index of starting position of range to move
fromColumn
Column index of starting position of range to move
toRow
Row index of starting position of destination
toColumn
Column index of starting position of destination
rowCount
Number of rows in range
columnCount
Number of columns in range

Glossary Item Box

Swaps the specified ranges of cells.

Syntax

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

Parameters

fromRow
Row index of starting position of range to move
fromColumn
Column index of starting position of range to move
toRow
Row index of starting position of destination
toColumn
Column index of starting position of destination
rowCount
Number of rows in range
columnCount
Number of columns in range

Exceptions

ExceptionDescription
System.ArgumentException Specified starting and ending row or row count is not valid
System.ArgumentException Specified starting and ending column or column count is not valid

Example

This example creates a DefaultSheetDataModel, assigns it to the DataModel of the spreadsheet and adds data to some of the cells. In a button click event, some of the data is swapped.
Visual BasicCopy Code
PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load

If(IsPostBack)ThenReturn

DimdmAsFarPoint.Web.Spread.Model.DefaultSheetDataModel=NewFarPoint.Web.Spread.Model.DefaultSheetDataModel(10,10)
FpSpread1.ActiveSheetView.DataModel=dm
dm.SetValue(0,0,1)
dm.SetValue(0,1,2)
dm.SetValue(0,2,3)
dm.SetValue(0,3,4)
dm.SetValue(0,4,5)
dm.SetValue(0,5,6)
dm.SetValue(1,0,100)
dm.SetValue(1,1,99)
dm.SetValue(1,2,98)
dm.SetValue(1,3,97)
dm.SetValue(1,4,96)
dm.SetValue(1,5,95)

EndSub

PrivateSubButton1_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesButton1.Click
DimdmAsFarPoint.Web.Spread.Model.DefaultSheetDataModel=FpSpread1.ActiveSheetView.DataModel
dm.Swap(0,0,0,2,2,2)
EndSub
C#Copy Code
privatevoidPage_Load(objectsender,System.EventArgse)
{
if(this.IsPostBack)return;

FpSpread1.ActiveSheetView.RowCount=10;
FpSpread1.ActiveSheetView.ColumnCount=10;

FpSpread1.ActiveSheetView.SetValue(0,0,1);
FpSpread1.ActiveSheetView.SetValue(0,1,2);
FpSpread1.ActiveSheetView.SetValue(0,2,3);
FpSpread1.ActiveSheetView.SetValue(0,3,4);
FpSpread1.ActiveSheetView.SetValue(0,4,5);
FpSpread1.ActiveSheetView.SetValue(0,5,6);
FpSpread1.ActiveSheetView.SetValue(1,0,100);
FpSpread1.ActiveSheetView.SetValue(1,1,99);
FpSpread1.ActiveSheetView.SetValue(1,2,98);
FpSpread1.ActiveSheetView.SetValue(1,3,97);
FpSpread1.ActiveSheetView.SetValue(1,4,96);
FpSpread1.ActiveSheetView.SetValue(1,5,95);
}

privatevoidButton1_Click(objectsender,System.EventArgse)
{
FarPoint.Web.Spread.Model.DefaultSheetDataModeldm=(FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.ActiveSheetView.DataModel;
dm.Swap(0,0,0,2,2,2);
}

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2002-2012 GrapeCity, Inc. All Rights Reserved.