如何在LookUpEdit中实现多列过滤
发布网友
发布时间:2022-05-03 02:43
我来回答
共1个回答
热心网友
时间:2022-07-01 15:56
ev控件的LookUpEdit控件的最大特点之一是下拉框的每一行可以是多列。但是该控件在绑定数据源之后,需要指定一列为ValueMember,表示下拉框中每一列的value,还需要指定一列为DisplayMember,表示选中一行后显示在控件的文本框中的值。正常情况下LookUpEdit默认只按displayValue的值进行自动匹配,要实现多列过滤代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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);