W3Schools Learner's Blog

W3Schools Programming knowledge summary website



devexpress gridview filter row in winform

devexpress gridview filter row in winform

how to filter row when you editing text in devexpress gridview? as follows:
//filter text EditValueChanging event
private void filter_column_text(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
this.gridView1.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never;
this.gridView1.ActiveFilterCriteria = BulidFilterCriteria();

private GroupOperator BulidFilterCriteria()
CriteriaOperatorCollection filterCollection = new CriteriaOperatorCollection();
filterCollection.Add(CriteriaOperator.Parse(string.Format("MTNO LIKE '%{0}%'", filter_text.Text)));
filterCollection.Add(CriteriaOperator.Parse(string.Format("MTNAME LIKE '%{0}%'", filter_text.Text)));
filterCollection.Add(CriteriaOperator.Parse(string.Format("PYCODE LIKE '%{0}%'", filter_text.Text)));
filterCollection.Add(CriteriaOperator.Parse(string.Format("WBCODE LIKE '%{0}%'", filter_text.Text)));
return new GroupOperator(GroupOperatorType.Or, filterCollection);
As shown in the picture:

GroupOperatorType is a enum type with two attributes of OR and And, and "Or" indicates that a column of conditions is displayed, and “And” indicates that the four column is met at the same time.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.