Devexpress lookupedit Multi-column filter

转自:http://blog.vsharing.com/janezhangxy/A1684672.html

private void FilterLookup(object sender)
{
    GridLookUpEdit edit = sender as GridLookUpEdit;
    GridView gridView = edit.Properties.View as GridView;
    FieldInfo fi = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance);
    BinaryOperator op1 = new BinaryOperator("ProductName", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
    BinaryOperator op2 = new BinaryOperator("PinYin", "%" + edit.AutoSearchText + "%", BinaryOperatorType.Like);
    string filterCondition = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] { op1, op2 }).ToString();
    fi.SetValue(gridView, filterCondition);
    MethodInfo mi = gridView.GetType().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic | BindingFlags.Instance);
    mi.Invoke(gridView, null);
}
private void lkpProductID_EditValueChanging(object sender, ChangingEventArgs e)
{
    this.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate
    {
        FilterLookup(sender);
    }));
}


你可能感兴趣的:(DevExpress)