Spread WPF Documentation
SortRange Method
Example 


The index of the starting row of the block of cells to sort.
The index of the starting column of the block of cells to sort.
The number of rows in the block of cells.
The number of columns in the block of cells.
Set to true to sort by rows; false to sort by columns.
The SortInfo object with sort criteria and information about how to perform the sort.
Sorts a range of cells in this sheet in the data model.
Syntax
'Declaration
 
Public Function SortRange( _
   ByVal row As System.Integer, _
   ByVal column As System.Integer, _
   ByVal rowCount As System.Integer, _
   ByVal columnCount As System.Integer, _
   ByVal byRows As System.Boolean, _
   ByVal sortInfo() As SortInfo _
) As System.Boolean
'Usage
 
Dim instance As Worksheet
Dim row As System.Integer
Dim column As System.Integer
Dim rowCount As System.Integer
Dim columnCount As System.Integer
Dim byRows As System.Boolean
Dim sortInfo() As SortInfo
Dim value As System.Boolean
 
value = instance.SortRange(row, column, rowCount, columnCount, byRows, sortInfo)
public System.bool SortRange( 
   System.int row,
   System.int column,
   System.int rowCount,
   System.int columnCount,
   System.bool byRows,
   SortInfo[] sortInfo
)

Parameters

row
The index of the starting row of the block of cells to sort.
column
The index of the starting column of the block of cells to sort.
rowCount
The number of rows in the block of cells.
columnCount
The number of columns in the block of cells.
byRows
Set to true to sort by rows; false to sort by columns.
sortInfo
The SortInfo object with sort criteria and information about how to perform the sort.

Return Value

true if the data is successfully sorted; otherwise, false.
Example
This example uses the SortRange method.
for (int i = 0; i < 10; i++)
            {
                gcSpreadSheet1.Sheets[0].SetValue(i, 0, i);
            }

 private void Button_Click(object sender, RoutedEventArgs e)
        {
            gcSpreadSheet1.Sheets[0].SortRange(0, 0, 10, 1, true, new SortInfo[] { new SortInfo(0, false) });
            gcSpreadSheet1.Invalidate();
        }
For i As Integer = 0 To 9
            GcSpreadSheet1.Sheets(0).SetValue(i, 0, i)
        Next

Private Sub Button_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
        GcSpreadSheet1.Sheets(0).SortRange(0, 0, 10, 1, True, New SortInfo() {New SortInfo(0, False)})
        GcSpreadSheet1.Invalidate()
    End Sub
Requirements

Target Platforms: Windows 7, Windows 8 Desktop, Windows Vista SP1 or later, Windows Server 2000, Windows 2000 Professional (SP4), Windows XP (SP2), Windows 2008, Windows 2003 Server (SP1)

See Also

Reference

Worksheet Class
Worksheet Members

 

 


Copyright © GrapeCity, inc. All rights reserved.