Skip to content

DevExpress-Examples/winforms-grid-customize-filter-criteria-before-apply

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Data Grid - Customize filter criteria before applying it

This example handles the SubstituteFilter event to modify the filter right before it is sent to the DataController. The event allows you to update or replace the filter with a custom filter.

private void GridView_SubstituteFilter(object sender, SubstituteFilterEventArgs e) {
    e.Filter &= CriteriaOperator.Parse("getyear(OrderDate) = ?", Convert.ToInt32(this.beiShowByYear.EditValue));
}
private void beiShowByYear_EditValueChanged(object sender, EventArgs e) {
    CriteriaOperator filter = this.GridView.ActiveFilterCriteria;
    this.GridView.BeginDataUpdate();
    try {
        this.GridView.ActiveFilterCriteria = null;
        this.GridView.ActiveFilterCriteria = filter;
    } finally {
        this.GridView.EndDataUpdate();
    }
}

Files to Review

See Also

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)