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


row
Index of the starting row of the block of cells to sort
column
Index of the starting column of the block of cells to sort
rowCount
Number of rows in the block of cells
columnCount
Number of columns in the block of cells
byRows
Whether to sort by rows (or else by columns)
sortInfo
SortInfo object with sort criteria and how to perform sort

Glossary Item Box

Sorts a range of cells on this sheet in the data model.

Syntax

Visual Basic (Declaration) 
Public Function SortRange( _
   ByVal row As Integer, _
   ByVal column As Integer, _
   ByVal rowCount As Integer, _
   ByVal columnCount As Integer, _
   ByVal byRows As Boolean, _
   ByVal sortInfo() As SortInfo _
) As Boolean
Visual Basic (Usage)Copy Code
Dim instance As SheetView
Dim row As Integer
Dim column As Integer
Dim rowCount As Integer
Dim columnCount As Integer
Dim byRows As Boolean
Dim sortInfo() As SortInfo
Dim value As Boolean
 
value = instance.SortRange(row, column, rowCount, columnCount, byRows, sortInfo)
C# 
public bool SortRange( 
   int row,
   int column,
   int rowCount,
   int columnCount,
   bool byRows,
   SortInfo[] sortInfo
)

Parameters

row
Index of the starting row of the block of cells to sort
column
Index of the starting column of the block of cells to sort
rowCount
Number of rows in the block of cells
columnCount
Number of columns in the block of cells
byRows
Whether to sort by rows (or else by columns)
sortInfo
SortInfo object with sort criteria and how to perform sort

Return Value

Boolean: true if successful; false otherwise.

Remarks

This method is for unbound data only. This method sorts the data in a range of cells by moving the data around in the data model and moving the cell-level styles along with it. This method is not intended for bound data, as it moves data (not necessarily by entire row or column) and has the effect of of moving the data around in the data source.

If byRows is true, the range is sorted by rows; if byRows if false, the range is sorted by columns.

With the sortInfo array, you can specify multiple criteria for sorting the data. This method gives you the ability to sort (or arrange) data in a smaller subset than entire rows or columns in a sheet. For more information, refer to the SortInfo object.

For bound data, use the SortColumns or SortRows methods. For a discussion of sorting, refer to Managing Sorting of Rows.

Example

This example sorts a range of cells in the sheet.
C#Copy Code
FarPoint.Win.Spread.SortInfo[] sort = new FarPoint.Win.Spread.SortInfo[1];
sort[0] = new FarPoint.Win.Spread.SortInfo(0, true, System.Collections.Comparer.Default);
fpSpread1.ActiveSheet.SetValue(0, 0, "C");
fpSpread1.ActiveSheet.SetValue(1, 0, "A");
fpSpread1.ActiveSheet.SetValue(2, 0, "E");
fpSpread1.ActiveSheet.SetValue(3, 0, "B");
fpSpread1.ActiveSheet.SetValue(0, 1, "3");
fpSpread1.ActiveSheet.SetValue(1, 1, "5");
fpSpread1.ActiveSheet.SetValue(2, 1, "1");
fpSpread1.ActiveSheet.SetValue(3, 1, "2");
fpSpread1.ActiveSheet.SortRange(0, 0, 4, 2, true, sort);
Visual BasicCopy Code
Dim sort(1) As FarPoint.Win.Spread.SortInfo
sort(0) = New FarPoint.Win.Spread.SortInfo(0, True, System.Collections.Comparer.Default)
FpSpread1.ActiveSheet.SetValue(0, 0, "C")
FpSpread1.ActiveSheet.SetValue(1, 0, "A")
FpSpread1.ActiveSheet.SetValue(2, 0, "E")
FpSpread1.ActiveSheet.SetValue(3, 0, "B")
FpSpread1.ActiveSheet.SetValue(0, 1, "3")
FpSpread1.ActiveSheet.SetValue(1, 1, "5")
FpSpread1.ActiveSheet.SetValue(2, 1, "1")
FpSpread1.ActiveSheet.SetValue(3, 1, "2")
FpSpread1.ActiveSheet.SortRange(0, 0, 4, 2, True, sort)

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.