property Columns.ItemBySortPosition (Position as Variant) as Column
Returns a Column object giving its sorting position.

 TypeDescription 
   Position as Variant A long expression that indicates the position of column being requested.  
   Column A Column object being accessed.  
Use the ItemBySortPosition property to get the list of sorted columns in their order. Use the SortPosition property to specify the position of the column in the sorting columns collection. Use the SingleSort property to specify whether the control supports sorting by single or multiple columns. Use the SortOrder property to sort a column programmatically. The control fires the Sort event when the user sorts a column.

The following  VB sample displays the list of columns being sorted:

Dim s As String, i As Long, c As Column
i = 0
With Gantt1.Columns
    Set c = .ItemBySortPosition(i)
    While (Not c Is Nothing)
        s = s + """" & c.Caption & """ " & IIf(c.SortOrder = SortAscending, "A", "D") & " "
        i = i + 1
        Set c = .ItemBySortPosition(i)
    Wend
End With
s = "Sort: " & s
Debug.Print s

The following VC sample displays the list of columns being sorted:

CString strOutput;
CColumns columns = m_gantt.GetColumns();
long i = 0;
CColumn column = columns.GetItemBySortPosition( COleVariant( i ) );
while ( column.m_lpDispatch )
{
	strOutput += "\"" + column.GetCaption() + "\" " + ( column.GetSortOrder() == 1 ? "A" : "D" ) + " ";
	i++;
	column = columns.GetItemBySortPosition( COleVariant( i ) );
}
OutputDebugString( strOutput );

The following VB.NET sample displays the list of columns being sorted:

With AxGantt1
    Dim s As String, i As Integer, c As EXGANTTLib.Column
    i = 0
    With AxGantt1.Columns
        c = .ItemBySortPosition(i)
        While (Not c Is Nothing)
            s = s + """" & c.Caption & """ " & IIf(c.SortOrder = EXGANTTLib.SortOrderEnum.SortAscending, "A", "D") & " "
            i = i + 1
            c = .ItemBySortPosition(i)
        End While
    End With
    s = "Sort: " & s
    Debug.WriteLine(s)
End With

The following C# sample displays the list of columns being sorted:

string strOutput = "";
int i = 0;
EXGANTTLib.Column column = axGantt1.Columns.get_ItemBySortPosition( i );
while ( column != null )
{
	strOutput += column.Caption + " " + ( column.SortOrder == EXGANTTLib.SortOrderEnum.SortAscending ? "A" : "D" ) + " ";
	column = axGantt1.Columns.get_ItemBySortPosition( ++i );
}
Debug.WriteLine( strOutput );

The following VFP sample displays the list of columns being sorted ( the code is listed in the Sort event ) :

local s, i, c
i = 0
s = ""
With thisform.Gantt1.Columns
    c = .ItemBySortPosition(i)
    do While (!isnull(c))
        with c
	        s = s + "'" + .Caption
	        s = s + "' " + IIf(.SortOrder = 1, "A", "D") + " "
	        i = i + 1
	    endwith
        c = .ItemBySortPosition(i)
    enddo
endwith
s = "Sort: " + s
wait window nowait s

 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.