资源简介
网上参照过别人的SearchLookUpEdit 多选,但是代码不全,零零散散,经过2个星期代码编写,测试,整理出了SearchLookUpEdit 多选功能实现的代码.
过程不易.代码量虽然只有200多行,但是经过几个版本的优化,性能完美.
望参与的同仁有更好的优化方法可以贴出来交流.
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid.Views.Grid;
namespace DataBind
{
public static class DataBind
{
public static void SearchLookUpDataBind(DataSet ds string valueMember string displayMember DevExpress.XtraEditors.SearchLookUpEdit searchLkpEdit bool isMultiSelect)
{
if (isMultiSelect)
{
searchLkpEdit.Properties.View.OptionsSelection.MultiSelect = true;
searchLkpEdit.Properties.View.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;
searchLkpEdit.Properties.View.OptionsCustomization.AllowSort = false; //禁止点击标题排序
EditorButton btnClear = new EditorButton(ButtonPredefines.Delete);
searchLkpEdit.Properties.Buttons.Add(btnClear);
searchLkpEdit.Popup += searchLkpEdit_Popup;
searchLkpEdit.Buttonclick += searchLkpEdit_Buttonclick;
searchLkpEdit.Closed += searchLkpEdit_Closed;
searchLkpEdit.CustomDisplayText += searchLkpEdit_CustomDisplayText;
searchLkpEdit.Properties.View.RowClick += searchLkpEditView_RowClick;
//添加选择框列供多选并且置为未选择状态
DataTable dt = ds.Tables[0];
dt.Columns.Add(“选择“ typeof(bool));
foreach (DataRow dr in dt.Rows)
{
dr[“选择“] = 0;
}
dt.Columns[“选择“].SetOrdinal(0);
}
//绑定数据源
searchLkpEdit.Properties.DataSource = ds.Tables[0];
searchLkpEdit.Properties.ValueMember = valueMember;
searchLkpEdit.Properties.DisplayMember = displayMember;
}
#region SearchLookUpEdit 控件多选私有方法
///
/// 弹出框事件
///
///
///
private static void searchLkpEdit_Popup(object sender EventArgs e)
{
DevExpress.XtraEditors.SearchLookUpEdit searchLkpEdit = sender as DevExpress.XtraEditors.SearchLookUpEdit;
//得到当前SearchLookUpEdit弹出窗体
DevExpress.XtraEditors.Popup.PopupSearchLookUpEditForm form = (sender as DevExpress.Utils.Win.IPopupControl).PopupWindow as DevExpress.XtraEditors.Popup.PopupSearchLookUpEditForm;
DevExpress.XtraGrid.Editors.SearchEditLookUpPopup popup = form.Controls.OfType().FirstOrDefault();
DevExpress.XtraLayout.LayoutControl layout = popup.Controls.OfType().FirstOrDefault();
if (layout.Controls.OfType().Where(ct => ct.Name == “btOK“).FirstOrDefault() == null)
{
- 上一篇:调用cyUSB.dllC#源码
- 下一篇:C#马的极小满覆盖
相关资源
- ShootSearch (基于dotlucene的c#开源搜索引
- 使用C#和控件DevExpress开发的一个小软
- 16.1全汉化,包括XAF、设计时刻、Win
- DevExpress9.2完整版
- Professional DevExpress ASP.NET Controls英文原
- Devexpress Winform中文文档.CHM
- DevExpress中文文档
- DevExpress winform XtraEditor常用控件
- DEV之物业管理
- Dev WinForm通用控件导出Excel方法(支持
- DEVExpress中文帮助文档.CHM版
- devexpress教程中文.chm
- devexpress控件说明大全
- DevExpress控件说明中文版-WinForm
- Professional+DevExpress+ASP.NET+Controls.pdf
- DevExpress WinForm中文文档
- DevexpressWinform中文文档
- Devexpress Winform中文文档纯中文文档N
- DevExpress控件forC#-8.2
- Devexpress 中文说明文档winform
- C# winform 经典ERP源码-采用了DevExpress
- DevExpress VCL 18.1.4 Full Sources完整源码
- DevExpress VCL V19.1.2 FullSource〖D7~D10.3Ri
- Winform控件库-DevExpressComponents-14.zip
- DevExpress VCL V18.2.8 FullSource〖D7~D10.3Ri
- winform 快速开发框架 仓库管理系统源
- Devexpress GridControl冻结头部几行
- devexpress Report demo asp.net
- Devexpress dxperience 13.1.5汉化资源
- winform devexpress 仓库管理系统源码
评论
共有 条评论