Spread Silverlight Documentation
SortInfo Constructor(Int32,Boolean,IComparer)
Example 


The index of the column or row on which to sort.
If set to true, sort order is ascending.
An System.Collections.IComparer object for the method of comparison.
Creates a SortInfo object with the specified order and comparison that uses a specified comparer.
Syntax
'Declaration
 
Public Function New( _
   ByVal index As System.Integer, _
   ByVal ascending As System.Boolean, _
   ByVal comparer As System.Collections.IComparer _
)
'Usage
 
Dim index As System.Integer
Dim ascending As System.Boolean
Dim comparer As System.Collections.IComparer
 
Dim instance As New SortInfo(index, ascending, comparer)
public SortInfo( 
   System.int index,
   System.bool ascending,
   System.Collections.IComparer comparer
)

Parameters

index
The index of the column or row on which to sort.
ascending
If set to true, sort order is ascending.
comparer
An System.Collections.IComparer object for the method of comparison.
Example
This example uses the SortInfo object.
public class CustomSortComparer : IComparer
    {
        public int Compare(object x, object y)
        {
            double xConvert = Convert.ToDouble(x.ToString());
            double yConvert = Convert.ToDouble(y.ToString());
            return Convert.ToInt32(xConvert - yConvert);
        }
    }

gcSpreadSheet1.Sheets[0].SetText(0, 0, "1");
gcSpreadSheet1.Sheets[0].SetText(1, 0, "10");
gcSpreadSheet1.Sheets[0].SetText(2, 0, "2");
gcSpreadSheet1.Sheets[0].SetText(3, 0, "20");
gcSpreadSheet1.Sheets[0].SetText(4, 0, "3");
gcSpreadSheet1.Sheets[0].SetText(5, 0, "30");
gcSpreadSheet1.Sheets[0].SortRange(0, 0, 6, 1, true, new SortInfo[] { new SortInfo(0, false,new CustomSortComparer()) });
gcSpreadSheet1.Invalidate();
Public Class CustomSortComparer
    Implements  IComparer
    Public Function Compare(x As Object, y As Object) As Integer Implements IComparer.Compare
        Dim xConvert As Double = Convert.ToDouble(x.ToString())
        Dim yConvert As Double = Convert.ToDouble(y.ToString())
        Return Convert.ToInt32(xConvert - yConvert)
    End Function
End Class

GcSpreadSheet1.Sheets(0).SetText(0, 0, "1")
GcSpreadSheet1.Sheets(0).SetText(1, 0, "10")
GcSpreadSheet1.Sheets(0).SetText(2, 0, "2")
GcSpreadSheet1.Sheets(0).SetText(3, 0, "20")
GcSpreadSheet1.Sheets(0).SetText(4, 0, "3")
GcSpreadSheet1.Sheets(0).SetText(5, 0, "30")
GcSpreadSheet1.Sheets(0).SortRange(0, 0, 6, 1, True, New SortInfo() {New SortInfo(0, False, New CustomSortComparer())})
GcSpreadSheet1.Invalidate()
Requirements

Target Platforms: Windows 7, Windows 8 Desktop, Windows Vista SP1 or later, Windows Server 2000, Windows 2000 Professional, Windows XP Professional, Windows NT 4.0 Workstation, SP6, Windows NT 4.0 Server, SP6

See Also

Reference

SortInfo Class
SortInfo Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.