强大DevExpress,Winform LookUpEdit 实现多列查询 gridview弹出下拉选择 z
关键代码请参考http://www.devexpress.com/Support/Center/p/K18333.aspx
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:
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:
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
强大DevExpress,Winform LookUpEdit 实现多列查询 gridview弹出下拉选择 z的更多相关文章
- Devexpres下LookUpEdit绑定数据后会默认弹出数据框的解决办法
LookUpEdit绑定数据后会默认弹出数据框很不友好问题现象: 问题解决前的代码: lueManagement.Text = groupEntity.Name; 2 lueManagement.Ed ...
- select2 智能补全模糊查询select2的下拉选择框使用
我们在上篇文章中已经在SpringMVC基础框架的基础上应用了BootStrap的后台框架,在此基础上记录select2的使用. 应用bootstrap模板 基础项目源码下载地址为: SpringMV ...
- DevExpress第三方控件使用实例之ASPxPopupControl弹出子窗体
弹出页面控件:ASPxPopupControl, <dxpc:ASPxPopupControl ID="popubCtr" runat="server" ...
- 2015-11-04 报表(c#部分)(Datatable 查询,弹出日期控件,输入是否整数)
using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq ...
- (转)winform(C#)里几种弹出对话框
//消息框中需要显示哪些按钮,此处显示“确定”和“取消” MessageBoxButtons messButton = MessageBoxButtons.OKCancel; //"确定要退 ...
- js中遍历出查询后的listmodel(下拉框系列)
function selectclassname(){ $.ajax({ url:"queryschoolclasslists.action", async:false, data ...
- [DevExpress]设置RepositoryItemComboBox只可下拉选择不可编辑
将TextEditStyle属性设置如下即可: 希望有所帮助!
- MVC联想查询绑定下拉框
前言 在做搜索时,输入些内容时需要弹出下拉框给用户进行选择,极大的方便了用户,会给用户带来不一样的体验 Controller public ActionResult SSAC(string UserN ...
- Winform如何实现ComboBox模糊查询
最近朋友问了一个关于Winform实现ComboBox模糊查询的知识点,自己好久没有搞Winform了,就上手练了一下,废话不多说,进入正题. 前台设计: 前台就是一个简单的Form窗体+一个Comb ...
随机推荐
- 选择排序、插入排序、冒泡排序python实现
选择排序的时间复杂度为O(n^2),是不稳定的排序 冒泡排序的时间复杂度最好情况下为O(n),最坏情况下为O(n^2),平均情况下为O(n^2),是稳定的排序 插入排序的时间复杂度最好情况下为O(n) ...
- 在TextView使用部分颜色文字
/** * change a part of string color. * * @param string * whole string. * @param subString * the sub ...
- 各种会义PPT
http://vdisk.weibo.com/s/dBzv2siaHK2H http://vdisk.weibo.com/wap/u/3460619722 https://yunqi.aliyun.c ...
- 【Unicode】字符编码表信息
UTF-8有点类似于Haffman编码,它将Unicode编码为:0x00-0x7F的字符,用单个字节来表示:0x80-0x7FF的字符用两个字节表示:0x800-0xFFFF的字符用3字节表示: ...
- Spring MVC 3.0.5+Spring 3.0.5+MyBatis3.0.4全注解实例详解(四)
这一章大象将详细分析web层代码,以及使用Spring MVC的注解及其用法和其它相关知识来实现控制器功能. 之前在使用Struts2实现MVC的注解时,是借助struts2-conventi ...
- Android(java)学习笔记143:android提供打开各种文件的API接口:setDataAndType
android 打开各种文件(setDataAndType) private void openFile(File file){ Intent intent = new Intent(); inten ...
- 自己动手实现SharePointList的分页展示
SharePoin列表里对条目的展示只有上一页下一页,不能够跳转,不能够一次导航到第一页和最后一页. 项目需要,所以对列表的数据展示进行了定制化开发来实现如上的功能. 前端用GridView展示,用L ...
- java Map的遍历
List下的Map的遍历方法 List<String> Keys =new ArrayList<String>(); ){ ;row<SheetData.size() ; ...
- Oracle之Merge用法
Merge用来从一个表中选择一些数据更新或者插入到另一个表中.而最终是用更新还是用插入的方式取决于该语句中的条件. 下面我们简单的举一个例子: SQL)) 表已创建. SQL)) 表已创建. SQL, ...
- 利用SQL语句给字段加注释
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色Id',--注释名称 @level0type=N'SCHEMA' ...