Hide

SftTree/NET 2.0 - Tree Control for Windows Forms

Display
Print

SetSortStatus Method, HeadersClass Class

Sets the sorting indicator of all header cells to the specified value.

Class: HeadersClass
Namespace: Softelvdm.SftTreeNET
Assembly: Softelvdm.SftTreeNET

Syntax

public void SetSortStatus( SortStatusEnum status );
Public Sub SetSortStatus( ByVal status As SortStatusEnum )

Parameters

status

The sorting indicator status.

Comments

Sets the sorting indicator of all header cells to the specified value.

A cell's sorting indicator can also be changed individually using the CellBaseClass.SortStatus property.

Examples

C#

        private bool SetSorted(int column)
        {
            bool fAscending = true; // assume new column will be ascending
            if (m_sortedColumn == column && sftTree1.Headers[0, column].SortStatus == SortStatusEnum.Ascending)
                fAscending = false; // the current column is now descending

            // turn off sorting indicator in all column headers
            sftTree1.Headers.SetSortStatus(SortStatusEnum.NotSorted);

           // now set the new sorting indicator
            sftTree1.Headers[0, column].SortStatus = fAscending ? SortStatusEnum.Ascending : SortStatusEnum.Descending;
            m_sortedColumn = column;
            return fAscending;
        }

        private void SortData(ItemClickEventArgs e)

VB.NET

Private Function SetSorted(ByVal column As Integer) As Boolean
    Dim fAscending As Boolean = True ' assume new column will be ascending
    If m_sortedColumn = column And sftTree1.Headers(0, column).SortStatus = SortStatusEnum.Ascending Then
        fAscending = False ' the current column is now descending
    End If

    ' turn off sorting indicator in all column headers
    sftTree1.Headers.SetSortStatus(SortStatusEnum.NotSorted)

   ' now set the new sorting indicator
    If fAscending Then
       sftTree1.Headers(0, column).SortStatus = SortStatusEnum.Ascending
    Else
        sftTree1.Headers(0, column).SortStatus = SortStatusEnum.Descending
    End If
    m_sortedColumn = column

See Also HeadersClass Class | Classes | SftTree/NET 2.0