Spread Windows Forms 7.0 Product Documentation
Moving Data on a Sheet
See Also Support Options
Spread Windows Forms 7.0 Product Documentation > Developer's Guide > Managing Data on a Sheet > Rearranging Data on a Sheet > Moving Data on a Sheet

Glossary Item Box

You can move data from one cell or range of cells to another using the Move methods for the sheet.

When you move data from one cell (or range of cells) to another, the data from the origination cell (or range of cells) replaces the data in the destination cell (or cells). If the operation moves a range of cells to an overlapping location, the values of all the cells of the range are replaced with the values of the cells in the moved range.

You can specify whether formulas are automatically updated when cells or ranges of cells are moved. For more information on automatic recalculation, refer to Recalculating and Updating Formulas Automatically.

To move data 3 rows up the sheet and 5 rows down, you would need to insert blank rows where you want to move the rows to. To move 3 rows up and 5 rows down, copy the five rows temporarily then move the 3 rows up to their positions and then assign the five copied rows to the right position.

Example

Here is code to do this.

C# Copy Code
With CType(FpSpread1.Sheets(0).DataModel, FarPoint.Win.Spread.Model.DefaultSheetDataModel)
FarPoint.Win.Spread.Model.DefaultSheetDataModel as new FarPoint.Win.Spread.Model.DefaultSheetDataModel(5, .ColumnCount);
dm.SetArray(0, 0, CType(FpSpread1.Sheets(0).DataModel, FarPoint.Win.Spread.Model.DefaultSheetDataModel).GetArray(0, 0, 5, 5));
.RemoveRows(0, 5);
.AddRows(0, 3);
.Move(.RowCount - 4, 0, 0, 0, 3, .ColumnCount);
.RemoveRows(.RowCount - 4, 3);
.AddRows(.RowCount, 5);
.SetArray(.RowCount - 6, 0, dm.GetArray(0, 0, 5, .ColumnCount));
End With
VB Copy Code
With CType(FpSpread1.Sheets(0).DataModel, FarPoint.Win.Spread.Model.DefaultSheetDataModel)
Dim dm As New FarPoint.Win.Spread.Model.DefaultSheetDataModel(5, .ColumnCount)
dm.SetArray(0, 0, CType(FpSpread1.Sheets(0).DataModel, FarPoint.Win.Spread.Model.DefaultSheetDataModel).GetArray(0, 0, 5, 5))
.RemoveRows(0, 5)
.AddRows(0, 3)
.Move(.RowCount - 4, 0, 0, 0, 3, .ColumnCount)
.RemoveRows(.RowCount - 4, 3)
.AddRows(.RowCount, 5)
.SetArray(.RowCount - 6, 0, dm.GetArray(0, 0, 5, .ColumnCount))
End With

See Also

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