event Sort ()
Fired when the control sorts a column. /*not supported in the lite version*/

 TypeDescription 
The control fires the Sort event when the control sorts a column ( the user clicks the column's header ) or when the sorting position is changed in the control's sort bar. Use the SortOnClick property to specify the action that control executes when the user clicks the column's head. Use the SortBarVisible property to show the control's sort bar. Use the SortOrder property to sorts a column at runtime. Use the SortPosition property to determine the position of the column in the sorting columns collection. Use the ItemBySortPosition property to access a column giving its position in the sorting columns collection. Use the Sort event to sort the data when the SortOnClk property is exUserSort. Use the SingleSort property to allow sorting by single or multiple columns.

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

Private Sub ComboBox1_Sort()
    Dim s As String, i As Long, c As Column
    i = 0
    With ComboBox1.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
End Sub

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

void OnSortComboBox1() 
{
	CString strOutput;
	CColumns columns = m_combobox.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:

Private Sub AxComboBox1_Sort(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxComboBox1.Sort
    With AxComboBox1
        Dim s As String, i As Integer, c As EXCOMBOBOXLib.Column
        i = 0
        With AxComboBox1.Columns
            c = .ItemBySortPosition(i)
            While (Not c Is Nothing)
                s = s + """" & c.Caption & """ " & IIf(c.SortOrder = EXCOMBOBOXLib.SortOrderEnum.SortAscending, "A", "D") & " "
                i = i + 1
                c = .ItemBySortPosition(i)
            End While
        End With
        s = "Sort: " & s
        Debug.WriteLine(s)
    End With
End Sub

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

private void axComboBox1_Sort(object sender, System.EventArgs e)
{
	string strOutput = "";
	int i = 0;
	EXCOMBOBOXLib.Column column = axComboBox1.Columns.get_ItemBySortPosition( i );
	while ( column != null )
	{
		strOutput += column.Caption + " " + ( column.SortOrder == EXCOMBOBOXLib.SortOrderEnum.SortAscending ? "A" : "D" ) + " ";
		column = axComboBox1.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.ComboBox1.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-2006 Exontrol Inc, Software. All rights reserved.