关键代码请参考http://www.devexpress.com/Support/Center/p/K18333.aspx

最新DEMO 下载

The current GridLookUpEdit's implementation doesn't provide interfaces to force the described feature to work automatically. However, in this article, we'll try to create a GridLookUpEdit's descendant and introduce the required behavior.

To accomplish this task, we'll have to create GridLookUpEdit and GridView descendants.

To force the drop-down grid to apply a proper filter condition, we need to override the OnCreateLookupDisplayFilter method. Here is some sample code:

[C#]Open in popup window
public class CustomGridView : GridView

{

    public CustomGridView() : base() { }

    protected override string OnCreateLookupDisplayFilter(string text, string displayMember)

    {

        string exp = LikeData.CreateContainsPattern(text);

        string searchString = "";

        foreach (GridColumn col in Columns)

        {

            if (col.Visible) 

                searchString = searchString + new BinaryOperator(col.FieldName, exp, BinaryOperatorType.Like).ToString() + " Or ";

        }

        searchString = searchString.Substring(0, searchString.Length - 4);

        return searchString;

    }

    protected virtual internal string GetExtraFilterText { get { return ExtraFilterText; } }

}

Additionally, it is necessary to highlight all found matches. To do this, we should override the view's painting mechanism. This can be done by creating our custom painter and by overriding the DrawRowCell method:

[C#]Open in popup window
public class CustomGridPainter : GridPainter

{

    public CustomGridPainter(GridView view) : base(view) { }

    public virtual new CustomGridView View { get { return (CustomGridView)base.View; } }

    protected override void DrawRowCell(GridViewDrawArgs e, GridCellInfo cell)

    {

        cell.ViewInfo.MatchedStringUseContains = true;

        cell.ViewInfo.MatchedString = View.GetExtraFilterText;

        cell.State = GridRowCellState.Dirty;

        e.ViewInfo.UpdateCellAppearance(cell);

        base.DrawRowCell(e, cell);

    }

}

Now you should properly register it, to make it available. Please refer to the How to create a GridView descendant class and register it for design-time use article to learn more on how to accomplish this.

Finally you should create a GridLookUpEdit descendant, an override the RepositoryItemGridLookUpEdit.CreateViewInstance and RepositoryItemGridLookUpEdit.CreateGrid methods.

The attached example contains descendants of the GridView, GridPainter, GridLookUpEdit, RepositoryItemGridLookUpEdit classes.
Additionally, there are GridControl and GridInfoRegistrator descendants for registering a custom grid view.

See Also:
How to create a GridView descendant class and register it for design-time use
Custom Editors

更多 0
 

强大DevExpress,Winform LookUpEdit 实现多列查询 gridview弹出下拉选择 z的更多相关文章

  1. Devexpres下LookUpEdit绑定数据后会默认弹出数据框的解决办法

    LookUpEdit绑定数据后会默认弹出数据框很不友好问题现象: 问题解决前的代码: lueManagement.Text = groupEntity.Name; 2 lueManagement.Ed ...

  2. select2 智能补全模糊查询select2的下拉选择框使用

    我们在上篇文章中已经在SpringMVC基础框架的基础上应用了BootStrap的后台框架,在此基础上记录select2的使用. 应用bootstrap模板 基础项目源码下载地址为: SpringMV ...

  3. DevExpress第三方控件使用实例之ASPxPopupControl弹出子窗体

    弹出页面控件:ASPxPopupControl, <dxpc:ASPxPopupControl ID="popubCtr" runat="server" ...

  4. 2015-11-04 报表(c#部分)(Datatable 查询,弹出日期控件,输入是否整数)

    using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq ...

  5. (转)winform(C#)里几种弹出对话框

    //消息框中需要显示哪些按钮,此处显示“确定”和“取消” MessageBoxButtons messButton = MessageBoxButtons.OKCancel; //"确定要退 ...

  6. js中遍历出查询后的listmodel(下拉框系列)

    function selectclassname(){ $.ajax({ url:"queryschoolclasslists.action", async:false, data ...

  7. [DevExpress]设置RepositoryItemComboBox只可下拉选择不可编辑

    将TextEditStyle属性设置如下即可: 希望有所帮助!

  8. MVC联想查询绑定下拉框

    前言 在做搜索时,输入些内容时需要弹出下拉框给用户进行选择,极大的方便了用户,会给用户带来不一样的体验 Controller public ActionResult SSAC(string UserN ...

  9. Winform如何实现ComboBox模糊查询

    最近朋友问了一个关于Winform实现ComboBox模糊查询的知识点,自己好久没有搞Winform了,就上手练了一下,废话不多说,进入正题. 前台设计: 前台就是一个简单的Form窗体+一个Comb ...

随机推荐

  1. Drawable、Bitmap、byte[]之间的转换

    android在处理一写图片资源的时候,会进行一些类型的转换: 1 Drawable → Bitmap 的简单方法 ((BitmapDrawable)res.getDrawable(R.drawabl ...

  2. 利用Qt制作一个helloworld

    使用QT创建第一个 工程: 1.打开应用程序: 2.单击画面中间偏上的 New Project按钮.[要学习使用啊~,传说它的跨平台行很好,QQ就是用它编辑的.] 3.直接点击右下角的选择 按钮. 4 ...

  3. semaphore(信号量)使用说明

    例子:      以一个停车场运作为例.为了简单起见,假设停车场只有三个车位,一开始三个车位都是空的.这时如果同时来了五辆车,看门人允许其中三辆不受阻碍的进入,然后放下车拦,剩下的车则必须在入口等待, ...

  4. 【腾讯Bugly干货分享】RecyclerView 必知必会

    本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:http://mp.weixin.qq.com/s/CzrKotyupXbYY6EY2HP_dA 导语 Re ...

  5. ffmpeg之移植到ARM

    移植方法分为两种:第一种手工移植,第二种buildroot移植. 第一种手工移植: 优点:灵活性高 缺点:重复工作多 一.配置 ./configure --enable-memalign-hack - ...

  6. MySQL基本查询语句

    创建一张表 create table user ( id ) not null, name ) not null, birthDate date not null, gender ) not null ...

  7. portal单点登录的原理与实现还有ESB

    portal单点登录的原理与实现还有ESB 在毕业论文中有描述到这一点.我给我出的截图

  8. json 转对象

    架包: import com.alibaba.fastjson.JSON; String arryStr="[{\"Name\": \"A\", \& ...

  9. UML类图细节

    类图表述的是类和类之间的关系,是前期用来推演代码设计,后期用来优化代码的结构,寻找设计不合理之处.网上解释类图和类图的画法,往往表述的十分晦涩,或者例子呆板,很难具体的操作. 类图一般在详细设计过程中 ...

  10. VIEW层AJAX提交表单到Controller的实体

    在MVC环境中,AJAX方式添加一个对象,这个对象在Models中是一个视图模型,在前台显示时是这样的代码: <%using (Html.BeginForm())      { %>    ...