Edit this page

Filtering

RadListControl can filter which items to be currently visible by using the Filter or FilterExpression properties.

Filtering predicate

The Filter property accepts a predicate method that can be used for arbitrary filtering conditions. The FilterExpession property accepts a string following a special syntax that describes which items should be visible. The Filter property is used like this:

Filtering method body

private bool FilterMethod(RadListDataItem itemToFilter)
{
    return itemToFilter.Text.EndsWith("SomeString");
}

Private Function FilterMethod(ByVal itemToFilter As RadListDataItem) As Boolean
    Return itemToFilter.Text.EndsWith("SomeString")
End Function

Setting the Filter property

radListControl1.Filter = FilterMethod;

radListControl1.Filter = AddressOf FilterMethod

Setting the Filter property will start a filtering operation which will call the FilterMethod for every item in RadListControl to determine if the item should be visible or not. After filtering, RadListControl will contain the same number of items as before or less. Setting the Filter property to null resets any filtering and all items will be visible.

caution

Filtering may change the SelectedIndex property depending on whether the currently selected item is still visible.

FilterExpression

Another option to filter the items is to specify the FilterExpression property.

Setting the FilterExpression property

this.radListControl1.FilterExpression = "Country LIKE 'Argentina'";

Me.radListControl1.FilterExpression = "Country LIKE 'Argentina'"
'#End Region
End Sub
'#Region "Binding"
Public Class Item
Public Property Id() As Integer
    Get
        Return m_Id
    End Get
    Set(value As Integer)
        m_Id = value
    End Set
End Property
Private m_Id As Integer
Public Property Description() As String
    Get
        Return m_Description
    End Get
    Set(value As String)
        m_Description = value
    End Set
End Property
Private m_Description As String
Public Sub New(id As Integer, description As String)
    Me.Id = id
    Me.Description = description
End Sub
End Class
Public Sub Bind()
Dim items As New List(Of Item)()
For i As Integer = 0 To 9
    items.Add(New Item(i, "Data" + i))
Next
radListControl1.DataSource = items
radListControl1.DisplayMember = "Description"
radListControl1.ValueMember = "Id"
End Sub
'#End Region
'#region creatingVisualListItem
Private Sub radListControl1_CreatingVisualListItem(ByVal sender As Object, ByVal args As CreatingVisualListItemEventArgs)
args.VisualItem = New CustomVisualItem()
End Sub