GridLookUpEdit 默认只按displayValue 的值进行自动匹配,
以下通过自定义可以实现多列自动匹配
Code和name 是列名。
void gridLookUpEdit1_Popup(object sender, EventArgs e) { FilterLookup(sender); } private void FilterLookup(object sender) { Text += " ! "; GridLookUpEdit edit = sender as GridLookUpEdit; GridView gridView = edit.Properties.View as GridView; FieldInfo fi = gridView.GetType().GetField("extraFilter", BindingFlags.NonPublic | BindingFlags.Instance); Text = edit.AutoSearchText; BinaryOperator op1 = new BinaryOperator("Code", edit.AutoSearchText + "%", BinaryOperatorType.Like); BinaryOperator op2 = new BinaryOperator("Name", 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 gridLookUpEdit1_EditValueChanging(object sender, ChangingEventArgs e) { this.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate{ FilterLookup(sender); })); }