DevExpress控件 LookupEdit 模糊查询

LookupEdit 的具体设置

 //单击回车按钮跳转下一个控件
 this.lookUpEdit1.EnterMoveNextControl = true; 

 //添加一个按钮,类型选择Delete,用来删除选中项
 this.lookUpEdit1.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo), new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Delete, "删除", -1, true, true, false, DevExpress.XtraEditors.ImageLocation.MiddleCenter, null, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.Delete), serializableAppearanceObject1, "删除选中项", "Delete", null, true)});

 //在输入框按任一可见字符键时立即弹出下拉窗体
 this.lookUpEdit1.Properties.ImmediatePopup = true; 

 this.lookUpEdit1.Properties.NullText = "[请输入……]";

 //不用显示表头
 this.lookUpEdit1.Properties.ShowHeader = false; 

 //允许选择编辑
 this.lookUpEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; 

 this.lookUpEdit1.Properties.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(this.lookUpEdit1_Properties_ButtonClick);
下面是Delete按钮的事件,设置LookupEdit的EditValue为null就可以清除选中的数据

        private void lookUpEdit1_Properties_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button.Kind== ButtonPredefines.Delete)
                lookUpCompanyName.EditValue = null;
        }
最后给lookUpEdit1的数据源Properties.DataSource 赋值就行了。


原文地址:https://www.cnblogs.com/rsls/p/4364107.html