110,539
社区成员
发帖
与我相关
我的任务
分享
//GridLookUpEdit模糊查询
private void FilterLookup(object sender, string[] arrFilterField)
{
//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;
CriteriaOperator[] arrCriteriaOperator = new CriteriaOperator[arrFilterField.Length];
for (int i = 0; i < arrFilterField.Length; i++)
{
arrCriteriaOperator[i] = new BinaryOperator(arrFilterField[i],"%"+edit.AutoSearchText + "%", BinaryOperatorType.Like);
}
string filterCondition = new GroupOperator(GroupOperatorType.Or, arrCriteriaOperator).ToString();
fi.SetValue(gridView, filterCondition);
MethodInfo mi = gridView.GetType().GetMethod("ApplyColumnsFilterEx", BindingFlags.NonPublic | BindingFlags.Instance);
mi.Invoke(gridView, null);
}
//绑定事件
void cmbZyzd_Properties_Popup(object sender, EventArgs e)
{
FilterLookup(sender, new string[] { "Name", "Code","Spell" });//中文,编码,拼音
}
void cmbZyzd_TextChanged(object sender, EventArgs e)
{
GridLookUpEdit edit = sender as GridLookUpEdit;
edit.SelectionStart = edit.Text.Length;
}
void cmbZyzd_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
{
this.BeginInvoke(new System.Windows.Forms.MethodInvoker(delegate
{
FilterLookup(sender, new string[] { "Name", "Code", "Spell" });
}));
}
//加载主要诊断
void LoadZyzd()
{
DataTable dt = new CDM_HB_ICD10BLL().GetZYZDData();//数据源
this.cmbZyzd.Properties.Popup -= new EventHandler(cmbZyzd_Properties_Popup);
this.cmbZyzd.EditValueChanging -= new DevExpress.XtraEditors.Controls.ChangingEventHandler(cmbZyzd_EditValueChanging);
this.cmbZyzd.TextChanged -= new EventHandler(cmbZyzd_TextChanged);
this.cmbZyzd.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
this.cmbZyzd.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True;
this.cmbZyzd.Properties.AutoComplete = false;
this.cmbZyzd.Properties.ImmediatePopup = true;
this.cmbZyzd.Properties.PopupFilterMode = DevExpress.XtraEditors.PopupFilterMode.Contains;
this.cmbZyzd.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
this.cmbZyzd.Properties.DataSource =dt;
this.cmbZyzd.Properties.ValueMember = "Code";
this.cmbZyzd.Properties.DisplayMember = "Name";
this.cmbZyzd.Properties.Popup += new EventHandler(cmbZyzd_Properties_Popup);
this.cmbZyzd.EditValueChanging += new DevExpress.XtraEditors.Controls.ChangingEventHandler(cmbZyzd_EditValueChanging);
this.cmbZyzd.TextChanged += new EventHandler(cmbZyzd_TextChanged);
}
可以去慢慢参悟,不懂的可以问我