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


keyRow
Index of the row to use as a key to sorting
ascending
Whether to sort in ascending order
comparer
IComparer object used to compare the values

Glossary Item Box

Sorts all the columns on the sheet by the specified row using the specified comparison.

Syntax

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

Parameters

keyRow
Index of the row to use as a key to sorting
ascending
Whether to sort in ascending order
comparer
IComparer object used to compare the values

Return Value

Boolean: true if successful; false otherwise

Remarks

This method can be used to sort all the columns in the sheet. It is similar to the simple method, SortColumns(Int32,Boolean), but adds an option for specifying the way of comparing that is used. Use this method to do a sort beyond the comparison technique provided by the comparer in the .NET framework.

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.
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.SortColumns(0, false, System.Collections.Comparer.Default);
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.SortColumns(0, False, System.Collections.Comparer.Default)

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.