DevExpress如何实现对LookUpEdit的模糊查询
1、我们利用一个TextEdit控件来作为搜索框,我们可以为该控件添加一些框内描述文字用来提示该控件是干什么用的,实现代码和效果图如下所示:DevExpress.XtraEditors.TextEditteSearch;teSearch.Properties.NullValuePromptShowForEmptyValue = true;teSearch.Properties.NullValuePrompt = "检索信息...";

3、接下来要在TextEdit的TextChanged事件中添加对LookUpEdit的模糊查询代码,当我们在TextEdit中输入文字时就会触发TextChanged事件,进而可以对LookUpEdit的数据源进行过滤查询。实现代码如下:privatevoidteSearch_TextChanged(objectsender, EventArgse){stringcontent = teTest.Text.Trim();if(string.IsNullOrEmpty(content)){lueTest.ClosePopup();lueTest.Properties.DataSource = _listEntity;lueTest.Properties.DropDownRows = _listEntity.Count;return;}List<LookUpEditEntity> newList = _listEntity.FindAll(t => t.Name.Contains(content));lueTest.Properties.DataSource = newList;lueTest.Properties.DropDownRows = newList.Count;lueTest.ShowPopup();}最终的实现效果如图所示。
