资源简介
ListView 单元格绑定下拉列表控件,文本框控件
可以绑定文本框,下拉列表框,图像,进度条,复选框,单选择,只要是继承Control类的控件都可以绑定
控件截图
http://blog.csdn.net/Linux7985/archive/2008/12/20/3562745.aspx
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace xYuanShian.ControlLibrary
{
///
/// 自定义ListView控件
///
public partial class ListEditView : UserControl
{
#region 私有成员
///
/// 行高
///
private int _LineHeight = 20;
///
/// 绑定项
///
private List _Items = new List();
///
/// 水平滚动事件
///
private const int WM_HSCROLL = 0x114;
///
/// 垂直滚动事件
///
private const int WM_VSCROLL = 0x115;
#endregion 私有成员
#region 公有属性
///
/// 指示包含控件中项及子项的行和列之间是否显示网络线
///
public bool GridLines
{
get { return this.ListViewCustom.GridLines; }
set { this.ListViewCustom.GridLines = value; }
}
///
/// 所有子控件集合
///
public ControlCollection ListViewControls
{
get { return this.ListViewCustom.Controls; }
}
///
/// 控件的行高
///
public int LineHeight { get { return _LineHeight; } set { _LineHeight = value; this.SetLineHeight(); } }
///
/// 项目集合
///
public List Items { get { return _Items; } }
#endregion 公有属性
#region 构造函数
///
/// 构造函数
///
public ListEditView()
{
InitializeComponent();
this.ListViewCustom.CheckBoxes = false;
this.ListViewCustom.FullRowSelect = true;
this.ListViewCustom.onscroll += ControlScroll;
this.ListViewCustom.DrawColumnHeader += DrawColumnHeader;
this.SetLineHeight();
}
#endregion 构造函数
#region 私有方法
///
/// 设置行高
///
private void SetLineHeight()
{
Image bitmap = new System.Drawing.Bitmap( 1 _LineHeight );
ImageList imgList = new ImageList();
imgList.ImageSize = new Size( 1 _LineHeight ); //分别是宽和高
imgList.Images.Add( bitmap );
this.ListViewCustom.SmallImageList = imgList;
}
///
/// 当列宽度改变时
///
///
///
private void DrawColumnHeader( object Sender DrawListViewColumnHeaderEventArgs ex )
{
this.MoveControl();
}
///
/// 滚动
///
///
///
private void ControlScroll( object sender bool vscroll )
{
this.MoveControl();
}
///
/// 删除控件
///
private void DelControl( ListEditViewItem items )
{
ListEditViewItem clv = items;
for ( int j = 0; j < this.ListViewCustom.Columns.Count; j++ )
{
EditViewColumnHeader ccl = this.ListViewCustom.Columns[j] as EditViewColumnHeader;
if ( ccl.Columnstyle == ListEditViewColumnstyle.Control )
{
Control tb1 = clv.Items[j] as Control;
tb1.Dispose();
}
}
}
///
/// 移动控
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9599 2008-12-21 00:25 ListEditView.cs
文件 2262 2008-12-20 22:24 ListEditView.Designer.cs
文件 6169 2008-12-20 20:54 ListEditView.resx
----------- --------- ---------- ----- ----
18030 3
评论
共有 条评论