资源简介
灵活:数据源、下拉框内显示的列、列名、可搜索关键字等可自由定义
方便:可输可选/支持键盘操作/模糊过滤/自动完成匹配
标准:通过继承combobox实现,可单独使用,也可嵌入datagridview使用
水平有限,欢迎大家多提宝贵意见,共同学习 QQ:41357935
本控件以“随风飘散”在 http://www.cnblogs.com/CodeAnyWhere/archive/2007/09/03/880780.html中的示例代码为基础改进而来,在此感谢!.
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Design;
namespace LWQ.MyControl
{
public class DataGridViewDataWindowCell:DataGridViewTextBoxCell
{
public override void InitializeEditingControl(int rowIndex object
initialFormattedValue DataGridViewCellstyle dataGridViewCellstyle)
{
base.InitializeEditingControl(rowIndex initialFormattedValue
dataGridViewCellstyle);
DataGridViewDataWindowEditingControl dataWindowControl =
DataGridView.EditingControl as DataGridViewDataWindowEditingControl;
dataWindowControl.PopupGridAutoSize = false;
DataGridViewDataWindowColumn dataWindowColumn=
(DataGridViewDataWindowColumn)OwningColumn;
dataWindowControl.sDisplayMember = dataWindowColumn.SDisplayMember;//以下3句必须放在datasource设置前面
dataWindowControl.sDisplayField = dataWindowColumn.SDisplayField;
dataWindowControl.sKeyWords = dataWindowColumn.SKeyWords;
dataWindowControl.DataSource = dataWindowColumn.DataSource;
dataWindowControl.Text = (string)this.Value;
dataWindowControl.RowFilterVisible = true; //此句必须放在datasource设置后面
}
[Browsable(false)]
public override Type EditType
{
get
{
return typeof(DataGridViewDataWindowEditingControl);
}
}
public override Type ValueType
{
get
{
return typeof(string);
}
}
private DataGridViewDataWindowEditingControl EditingDataWindow
{
get
{
DataGridViewDataWindowEditingControl dataWindowControl =
DataGridView.EditingControl as DataGridViewDataWindowEditingControl;
return dataWindowControl;
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-06-07 11:15 WindowsFormsApplication2\
文件 962 2012-06-05 14:43 WindowsFormsApplication2.sln
目录 0 2012-06-07 11:15 WindowsFormsApplication2\bin\
目录 0 2012-06-07 11:15 WindowsFormsApplication2\bin\Debug\
文件 28672 2012-06-07 11:15 WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe
文件 67072 2012-06-07 11:15 WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.pdb
文件 14328 2012-06-05 14:43 WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe
文件 490 2009-06-11 05:14 WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.manifest
文件 2199 2012-06-05 14:44 WindowsFormsApplication2\DataGridViewDataWindowCell.cs
文件 2109 2012-06-05 14:44 WindowsFormsApplication2\DataGridViewDataWindowColumn.cs
文件 4729 2012-06-05 14:44 WindowsFormsApplication2\DataGridViewDataWindowEditingControl.cs
文件 18005 2012-06-07 10:15 WindowsFormsApplication2\DataWindow.cs
文件 6454 2012-06-07 11:15 WindowsFormsApplication2\Form1.cs
文件 12323 2012-06-07 11:15 WindowsFormsApplication2\Form1.Designer.cs
文件 5814 2012-06-07 11:15 WindowsFormsApplication2\Form1.resx
目录 0 2012-06-05 14:43 WindowsFormsApplication2\obj\
目录 0 2012-06-07 11:15 WindowsFormsApplication2\obj\Debug\
目录 0 2012-06-07 10:22 WindowsFormsApplication2\obj\Debug\Refactor\
目录 0 2012-06-05 14:43 WindowsFormsApplication2\obj\Debug\TempPE\
文件 1235 2012-06-07 11:15 WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.FileListAbsolute.txt
文件 847 2012-06-07 11:15 WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.GenerateResource.Cache
文件 28672 2012-06-07 11:15 WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.exe
文件 180 2012-06-07 11:15 WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Form1.resources
文件 67072 2012-06-07 11:15 WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.pdb
文件 180 2012-06-07 11:15 WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Properties.Resources.resources
文件 505 2012-06-05 14:43 WindowsFormsApplication2\Program.cs
目录 0 2012-06-05 14:43 WindowsFormsApplication2\Properties\
文件 1380 2012-06-05 14:43 WindowsFormsApplication2\Properties\AssemblyInfo.cs
文件 2898 2012-06-05 14:43 WindowsFormsApplication2\Properties\Resources.Designer.cs
文件 5612 2012-06-05 14:43 WindowsFormsApplication2\Properties\Resources.resx
文件 1109 2012-06-05 14:43 WindowsFormsApplication2\Properties\Settings.Designer.cs
............此处省略2个文件信息
评论
共有 条评论