GrapeCity.Xaml.SpreadSheet.Data
SortInfo Constructor(Int32,Boolean,IComparer)
Example 


GrapeCity.Xaml.SpreadSheet.Data Namespace > SortInfo Class > SortInfo Constructor : SortInfo Constructor(Int32,Boolean,IComparer)
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 Integer, _
   ByVal ascending As Boolean, _
   ByVal comparer As IComparer _
)
'Usage
 
Dim index As Integer
Dim ascending As Boolean
Dim comparer As IComparer
 
Dim instance As New SortInfo(index, ascending, comparer)
public SortInfo( 
   int index,
   bool ascending,
   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 sorts a range.
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 GrapeCity.Xaml.SpreadSheet.Data.SortInfo[] { new GrapeCity.Xaml.SpreadSheet.Data.SortInfo(0, false,new CustomSortComparer()) });
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 GrapeCity.Xaml.SpreadSheet.Data.SortInfo() {New GrapeCity.Xaml.SpreadSheet.Data.SortInfo(0, False, New CustomSortComparer())})
See Also

Reference

SortInfo Class
SortInfo Members
Overload List