method ComboBox.ApplyFilter ()
Applies the filter. /*not supported in the lite version*/

 TypeDescription 

The ApplyFilter method updates the control's content once that user sets the filter using the Filter and FilterType properties. Use the VisibleItemCount property to specify the number of visible items in the list. Use the ClearFilter method to clear the control's filter. Use the DisplayFilterButton property to show the filter drop down button in the column's caption. Use the FilterBarCaption property to specify a new caption for the control's filter bar when a filter is applied. Use the FilterBarHeight property to specify the height of the control's filter bar. Use the FilterInclude property to specify whether the child items should be included to the list when the user applies the filter. Use the FilterCriteria property to filter items using AND, OR or NOT operators between columns. 

The following VB sample filters for items that contains the string you typed so far ( the control's Style property is DropDownList ):

Option Explicit
Dim s As String

Private Sub ComboBox1_FilterChange()
    With ComboBox1.Columns(0)
        If (.FilterType = exAll) Then
            s = ""
        End If
    End With
    If (Len(s) > 0) Then
        ComboBox1.FilterBarCaption = "Include only the items that contain ' " & s & "'. "
    End If
End Sub

Private Sub ComboBox1_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = vbKeyDelete) Then
        s = ""
        ComboBox1.ClearFilter
    End If
End Sub

Private Sub ComboBox1_KeyPress(KeyAscii As Integer)
    If (KeyAscii = vbKeyBack) Then
        If (Len(s) > 0) Then
            s = Left(s, Len(s) - 1)
        End If
    Else
        s = s + Chr(KeyAscii)
    End If
    
    With ComboBox1
        If (Len(s) > 0) Then
            With .Columns(0)
                .Filter = "*" & s & "*"
                .FilterType = exPattern
            End With
            .ApplyFilter
        Else
            .ClearFilter
        End If
    End With
End Sub

Private Sub Form_Load()
    ' The data is loaded at design time, using the
    ' control's Template page
    With ComboBox1.Columns(0)
        .AutoSearch = exContains
    End With
End Sub

The following VB sample filters "Child 1" and "Child 2" items:

With ComboBox1
    With .Columns(0)
        .Filter = "Child 1|Child 2"
        .FilterType = exPattern
    End With
    .ApplyFilter
End With

The following C++ sample filters "Child 1" and "Child 2" items:

CColumn column = m_combobox.GetColumns().GetItem(COleVariant(long(0)));
column.SetFilter( "Child 1|Child 2" );
column.SetFilterType( 3 /*exPattern*/ );
m_combobox.ApplyFilter();

The following VB.NET sample filters "Child 1" and "Child 2" items:

With AxComboBox1
    With .Columns(0)
        .Filter = "Child 1|Child 2"
        .FilterType = EXCOMBOBOXLib.FilterTypeEnum.exPattern
    End With
    .ApplyFilter()
End With

The following C# sample filters "Child 1" and "Child 2" items:

axComboBox1.Columns[0].Filter = "Child 1|Child 2";
axComboBox1.Columns[0].FilterType = EXCOMBOBOXLib.FilterTypeEnum.exPattern;
axComboBox1.ApplyFilter();

The following VFP sample filters "Child 1" and "Child 2" items:

With thisform.ComboBox1
    With .Columns.Item(0)
        .Filter = "Child 1|Child 2"
        .FilterType = 3 && exPattern
    EndWith
    .ApplyFilter
EndWith

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