关键代码请参考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. Yii CGridView 基本使用(三)关联表相关字段搜索

    加入 关联表 相关字段的搜索: 先说一句,我们在这里仅仅谈 "一对多" 的关联搜索,首先,不要忘了我们的数据库,忘记的同学请戳这里:这里.能够看到在 tbl_post 中是有一个外 ...

  2. 新型信用卡MasterPass

    Xsolla与masterpass合作.提供新型支付方式 "电子支付的未来在这里. "在万事达卡宣布发行一种全新的被称为MasterPass的支付解决方式的两年后.从2014年底開 ...

  3. mysql优化之索引优化

    Posted by Money Talks on 2012/02/23 | 第一篇 序章第二篇 连接优化第三篇 索引优化第四篇 查询优化第五篇 到实战中去 索引优化 索引优化涉及到几个方面,包括了索引 ...

  4. C++ ORM ODB 入门介绍(一)

    C++的语言特性决定了在C++中的ORM框架不可能像Java,C#那没有那么灵活. C++的ORM框架一般都是基于模板,编译时,因此其效率比起Java中的ORM框架更高. ODB是一个比较独立,成熟的 ...

  5. asp遇到的一些问题

    1.伪静态问题...后台设置支持, 2.数据库链接错误,也就是说  .net 功能冲突,要后台关闭 3.本机也可以设置 iis服务器 win7配置自己的IIS服务器亲自做的图文很详细 http://j ...

  6. JNI 学习笔记系列(二)

    c中没有Boolean类型的值,一般是使用1表示true,0表示false,c中也没有String类型的数据,c中的字符串要通过char数组来表示.c中没有byte类型,一般用char表示byte类型 ...

  7. frameset和iframe--框架对象及元素标签对象

    chrome不兼容:不支持跨frame的变量的获取 var oParent = parent.document.getElementById('contentFrm'); //frameset标签对象 ...

  8. Asp.net上传出现“超过了最大请求长度”的问题解决方法

    在开发ASP.NET网站后台管理系统时,我们可能会遇到这样的问题:上传大于4M的文件时,会提示错误:错误信息如下: 1.异常详细信息:超过了最大请求长度. 2.引发异常的方法:Byte[] GetEn ...

  9. xml_03

    1.xml 2.对于XML文档的约束   |-DTD      <!DOCTYPE 根元素 [       <!ELEMENT 元素名 (xx)>       <!ATTLIS ...

  10. 将分页功能从JSP页面中独立出来

    附带视频链接:http://www.tudou.com/programs/view/leaQ-YFl7W8/?bid=03&pid=2&resourceId=0_03_05_02