Spread Windows Forms 8.0 Product Documentation
SortColumns(Int32,Boolean) Method
Example 


Index of the row to use as a key to sorting
Whether to sort in ascending order
Sorts all the columns on the sheet by the specified row.
Syntax
'Declaration
 
Public Overloads Function SortColumns( _
   ByVal keyRow As Integer, _
   ByVal ascending As Boolean _
) As Boolean
'Usage
 
Dim instance As SheetView
Dim keyRow As Integer
Dim ascending As Boolean
Dim value As Boolean
 
value = instance.SortColumns(keyRow, ascending)
public bool SortColumns( 
   int keyRow,
   bool ascending
)

Parameters

keyRow
Index of the row to use as a key to sorting
ascending
Whether to sort in ascending order

Return Value

Boolean: true if successful; false otherwise
Remarks

This is the simplest of the methods to sort columns. It sorts the arrangement of columns in a sheet using one row as the key. You need only specify the row to use as a key for sorting and whether the sort is ascending or descending. All the columns in the sheet are sorted.

This does not affect the data model, only how the data is displayed. Different overloads provide different ways to sort the columns. For a discussion of sorting, refer to Managing Sorting of Rows.

Example
This example sorts a range of columns.
fpSpread1.ActiveSheet.SetValue(0, 0, "S");
fpSpread1.ActiveSheet.SetValue(0, 1, "E");
fpSpread1.ActiveSheet.SetValue(0, 2, "A");
fpSpread1.ActiveSheet.SetValue(0, 3, "K");
fpSpread1.ActiveSheet.SetValue(1, 0, "W");
fpSpread1.ActiveSheet.SetValue(1, 1, "G");
fpSpread1.ActiveSheet.SetValue(1, 2, "P");
fpSpread1.ActiveSheet.SetValue(1, 3, "V");
fpSpread1.ActiveSheet.SetValue(2, 0, "O");
fpSpread1.ActiveSheet.SetValue(2, 1, "L");
fpSpread1.ActiveSheet.SetValue(2, 2, "Q");
fpSpread1.ActiveSheet.SetValue(2, 3, "H");
fpSpread1.ActiveSheet.SortColumns(0, false);
FpSpread1.ActiveSheet.SetValue(0, 0, "S")
FpSpread1.ActiveSheet.SetValue(0, 1, "E")
FpSpread1.ActiveSheet.SetValue(0, 2, "A")
FpSpread1.ActiveSheet.SetValue(0, 3, "K")
FpSpread1.ActiveSheet.SetValue(1, 0, "W")
FpSpread1.ActiveSheet.SetValue(1, 1, "G")
FpSpread1.ActiveSheet.SetValue(1, 2, "P")
FpSpread1.ActiveSheet.SetValue(1, 3, "V")
FpSpread1.ActiveSheet.SetValue(2, 0, "O")
FpSpread1.ActiveSheet.SetValue(2, 1, "L")
FpSpread1.ActiveSheet.SetValue(2, 2, "Q")
FpSpread1.ActiveSheet.SetValue(2, 3, "H")
FpSpread1.ActiveSheet.SortColumns(0, False)
Requirements

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

See Also

Reference

SheetView Class
SheetView Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.