vb.netwinformsdevexpressxtragrid

how to change devexpress xtragrid autofiltercontion beginwith to contains?


I am using devexpress 16.1 version, enable autofilter mode using columnheader, when i enter values its filter by begin character, but i want to filter contains, for example , i want to get "manager", i will enter "nage". am tried with this, but while filtering my filter values are empty

 Dim filterstr As String = GridView1.FocusedValue
 GridView1.ActiveFilterString = "Contains([" & HitColumnName & "]" & "," & "'" & filterstr & "'" & ")"

Thanks in Advance


Solution

  • You can change the filter condition in the OptionsColumn.AutoFilterCondition property for every column in GridView.

    I suggest you to go through documentation of XtraGrid Filtering:
    Tutorial: Column Filter Dropdowns
    Tutorial: Data Filtering Basics and Filter Panel Settings

    You can set it in Designer in column properties: enter image description here

    and pragmatically as below:

    gridView1.Columns[0].OptionsFilter.AutoFilterCondition = DevExpress.XtraGrid.Columns.AutoFilterCondition.Contains; 
    

    References:
    XtraGrid - Provide a property to change filtering type from "begins with" to "contains", etc.
    How to set filter condition as CONTAINS for AutoFilter row through code at grid level
    How to set auto filter row text of specific columns via code