Set default filter operators in RadGridView


Product Version Product Author
2018.3.1016 RadGridView for WinForms Desislava Yordanova


The default filter operator in the RadGridView's columns depends on the data type that is being stored in that column. For example, the default filter operator for a text column is Contains. This article will demonstrate a sample approach how to change it and apply another relevant filter operator for this data type.

set-default-filter-operators-in-gridview 001


Subscribe to the RadGridView.CreateCell event and replace the default GridFilterCellElement with your custom one where you can specify the default filter operator, e.g. StartsWith:

Custom filter cell element

        private void radGridView1_CreateCell(object sender, Telerik.WinControls.UI.GridViewCreateCellEventArgs e)
            if (e.CellType == typeof(GridFilterCellElement) && e.Column.Name == "ProductName")
                e.CellElement = new CustomGridFilterCellElement(e.Column as GridViewDataColumn,e.Row);

        public class CustomGridFilterCellElement : GridFilterCellElement
            protected override Type ThemeEffectiveType    
                    return typeof(GridFilterCellElement);    

            public CustomGridFilterCellElement(GridViewDataColumn column, GridRowElement row) : base(column, row)

    Private Sub radGridView1_CreateCell(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCreateCellEventArgs)
        If e.CellType = GetType(GridFilterCellElement) AndAlso e.Column.Name = "ProductName" Then
            e.CellElement = New CustomGridFilterCellElement(TryCast(e.Column, GridViewDataColumn), e.Row)
        End If
    End Sub

    Public Class CustomGridFilterCellElement
    Inherits GridFilterCellElement

        Protected Overrides ReadOnly Property ThemeEffectiveType As Type
                Return GetType(GridFilterCellElement)
            End Get
        End Property

        Public Sub New(ByVal column As GridViewDataColumn, ByVal row As GridRowElement)
            MyBase.New(column, row)
        End Sub
    End Class

As a result, the default filter operator for the ProductName column is changed:

set-default-filter-operators-in-gridview 002

See Also

In this article
Not finding the help you need? Improve this article