首页 > 代码库 > GridLookUpEdit多列模糊查询最简单方式 z
GridLookUpEdit多列模糊查询最简单方式 z
GridLookUpEdit的知识库是RepositoryItemGridLookUpEdit,切确的说GridLookUpEdit只是RepositoryItemGridLookUpEdit的一个壳而已,
这也就是在GridControl的GridView中,对列绑定的是RepositoryItemGridLookUpEdit而不是GridLookUpEdit的原因,RepositoryItemGridLookUpEdit才是GridLookUpEdit的核心,所以处理这个过滤操作,其实就是对RepositoryItemGridLookUpEdit进行操作,
方法的参数也是RepositoryItemGridLookUpEdit类型,这样在GridView中使用RepositoryItemGridLookUpEdit也可以直接调用。eg:
SetGridLookUpEditMoreColumnFilter(gridLookUpEdit1.Properties);
SetGridLookUpEditMoreColumnFilter(repositoryItemGridLookUpEdit1);
/// <summary> /// 设置GridLookUpEdit多列过滤 /// </summary> /// <param name="repGLUEdit">GridLookUpEdit的知识库,eg:gridlookUpEdit.Properties</param> void SetGridLookUpEditMoreColumnFilter(DevExpress.XtraEditors.Repository.RepositoryItemGridLookUpEdit repGLUEdit) { repGLUEdit.EditValueChanging += (sender, e) => { this.BeginInvoke(new System.Windows.Forms.MethodInvoker(() => { GridLookUpEdit edit = sender as GridLookUpEdit; DevExpress.XtraGrid.Views.Grid.GridView view = edit.Properties.View as DevExpress.XtraGrid.Views.Grid.GridView; //获取GriView私有变量 System.Reflection.FieldInfo extraFilter = view.GetType().GetField("extraFilter",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); List<DevExpress.Data.Filtering.CriteriaOperator> columnsOperators = new List<DevExpress.Data.Filtering.CriteriaOperator>(); foreach (GridColumn col in view.VisibleColumns) { if (col.Visible && col.ColumnType == typeof(string)) columnsOperators.Add(new DevExpress.Data.Filtering.FunctionOperator(DevExpress.Data.Filtering.FunctionOperatorType.Contains, new DevExpress.Data.Filtering.OperandProperty(col.FieldName), new DevExpress.Data.Filtering.OperandValue(edit.Text))); } string filterCondition = new DevExpress.Data.Filtering.GroupOperator(DevExpress.Data.Filtering.GroupOperatorType.Or, columnsOperators).ToString(); extraFilter.SetValue(view, filterCondition); //获取GriView中处理列过滤的私有方法 System.Reflection.MethodInfo ApplyColumnsFilterEx = view.GetType().GetMethod("ApplyColumnsFilterEx", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); ApplyColumnsFilterEx.Invoke(view, null); })); }; }
GridLookUpEdit多列模糊查询最简单方式 z
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。