关键代码请参考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. oracle调优 浅析关联设计

    浅析关联设计 [范式] 比較理想的情况下,数据库中的不论什么一个表都会相应到现实生活中的一个对象,如球员是一个对象,球队是一个对象,赛程是一个对象,比赛结果又是一个对象等等,则就是范式. [关联设计] ...

  2. 【Android】BroadCast广播机制应用与实例

    如何编写广播接收器 第一步:需要继承BroadcastReceiver类,覆写其中的onReceive()方法. class MyBroadcastReceiver extends Broadcast ...

  3. hdu4462 Scaring the Birds

    Scaring the Birds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  4. C# - 系统类 - Array类

    Array类 ns:System Array是一个抽象类 表示数组 提供了创建.查找.删除.排序.修改等应用于数组的操作 此类没有公有的实例构造函数 可以使用静态方法CreateInstance创建A ...

  5. Mac system快捷键

    官方的快捷键是 control+command+F 进行窗口和全屏的切换. 1042282500@qq.com yss12313

  6. 使用OKHttp模拟登陆知乎,兼谈OKHttp中Cookie的使用!

    本文主要是想和大家探讨技术,让大家学会Cookie的使用,切勿做违法之事! 很多Android初学者在刚开始学习的时候,或多或少都想自己搞个应用出来,把自己学的十八般武艺全都用在这个APP上,其实这个 ...

  7. Verilog HDL常用的行为仿真描述语句

    一.循环语句 1.forever语句 forever语句必须写在initial模块中,主要用于产生周期性波形. 2.利用for.while循环语句完成遍历 for.while语句常用于完成遍历测试.当 ...

  8. sklearn两种保存模型的方式

    作者:卢嘉颖 链接:https://www.zhihu.com/question/27187105/answer/97334347 来源:知乎 著作权归作者所有,转载请联系作者获得授权. 1. pic ...

  9. Python入门学习教程:数据库操作,连接MySql数据库

    各位志同道合的同仁可以点击上方关注↑↑↑↑↑↑ 本教程致力于程序员快速掌握Python语言编程. 本文章内容是基于上次课程Python教程:Python教程:连接数据库,对数据进行增删改查操作 和py ...

  10. android studio环境搭建-笔记1

    自己干了几年测试(功能性的),最近比较闲,就自己学习下android(以前也有所接触,但那是几年前的一点皮毛,都忘记了). 先搭建谷歌推出的android studio(以前用eclipse搭建总觉得 ...