Hide

SftTree/NET 2.0 - Tree Control for Windows Forms

Display
Print

SortAscending Class

Default implementation of an IComparer interface used with the ItemCollectionClass.Sort method to sort items in an ascending fashion, based on the cell text in a specified column.

Namespace: Softelvdm.SftTreeNET
Assembly: Softelvdm.SftTreeNET

Inheritance

Syntax

public  sealed class SortAscending;
Public  NotInheritable Class SortAscending

Constructors

PublicSortAscendingInitializes a new instance of the SortAscending class.

Methods

PublicCompareCompares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
PublicInherited from System.ObjectEqualsDetermines whether the specified object is equal to the current object.
ProtectedInherited from System.ObjectFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
PublicInherited from System.ObjectGetHashCodeServes as the default hash function.
PublicInherited from System.ObjectGetTypeGets the Type of the current instance.
ProtectedInherited from System.ObjectMemberwiseCloneCreates a shallow copy of the current Object.
PublicStaticInherited from System.ObjectReferenceEqualsDetermines whether the specified Object instances are the same instance.
PublicInherited from System.ObjectToStringReturns a string that represents the current object.

Examples

C#

            if (e.Area != ItemClickAreaEnum.Cell)
                return;

            bool fAscending = SetSorted(e.Cell.ColumnIndex);

            switch (e.Cell.ColumnIndex) {
            default: // column 0 and 1 are sorted based on the Text property
                if (fAscending)
                    sftTree1.ItemCollection.Sort(new SortAscending(e.Cell.ColumnIndex));
                else
                    sftTree1.ItemCollection.Sort(new SortDescending(e.Cell.ColumnIndex));
                break;
            case 2: case 3: // column 2 and 3 are sorted based on the TagObject property, interpreted as a long
                if (fAscending)
                    sftTree1.ItemCollection.Sort(new SortTagObjectAsLongAscending(e.Cell.ColumnIndex));
                else

VB.NET

    Case 2, 3 ' column 2 and 3 are sorted based on the TagObject property, interpreted as a long
        If fAscending Then
            sftTree1.ItemCollection.Sort(New SortTagObjectAsLongAscending(e.Cell.ColumnIndex))
        Else
            sftTree1.ItemCollection.Sort(New SortTagObjectAsLongDescending(e.Cell.ColumnIndex))
        End If
    Case Else ' column 0 and 1 are sorted based on the Text property
        If fAscending Then
            sftTree1.ItemCollection.Sort(New SortAscending(e.Cell.ColumnIndex))
        Else
            sftTree1.ItemCollection.Sort(New SortDescending(e.Cell.ColumnIndex))
        End If
    End Select
End Sub

' ItemClick event

See Also Classes | SftTree/NET 2.0