Spread Windows Forms 7.0 Product Documentation
SortRows(Int32,Boolean,Boolean) Method
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SheetView Class > SortRows Method : SortRows(Int32,Boolean,Boolean) Method


keyColumn
Column index whose values are compared during sorting
ascending
Whether to sort in ascending order
showIndicator
Whether the sort indicator should be displayed

Glossary Item Box

Sorts all the rows on this sheet by the specified column.

Syntax

Visual Basic (Declaration) 
Public Overloads Function SortRows( _
   ByVal keyColumn As Integer, _
   ByVal ascending As Boolean, _
   ByVal showIndicator As Boolean _
) As Boolean
Visual Basic (Usage)Copy Code
Dim instance As SheetView
Dim keyColumn As Integer
Dim ascending As Boolean
Dim showIndicator As Boolean
Dim value As Boolean
 
value = instance.SortRows(keyColumn, ascending, showIndicator)
C# 
public bool SortRows( 
   int keyColumn,
   bool ascending,
   bool showIndicator
)

Parameters

keyColumn
Column index whose values are compared during sorting
ascending
Whether to sort in ascending order
showIndicator
Whether the sort indicator should be displayed

Return Value

Boolean: true if successful; false otherwise

Remarks

This is the simplest of the methods to sort rows. You need only specify the following:

  • the column to use as a key for sorting
  • whether the sort is ascending or descending
  • whether to show the sort indicator in the column header or not

All the rows in the sheet are sorted. Use this method to sort the arrangement of rows in a sheet using one or more columns as the key.

This does not affect the data model, only how the data is displayed. Different overloads provide different ways to sort the rows.

Example

This example sorts a range of rows.
C#Copy Code
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.SortRows(1, false, true);
Visual BasicCopy Code
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.SortRows(1, False, True)

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

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