首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么在一个DataGridView中的一列添加DateTimePicker控件

2011-12-10 
如何在一个DataGridView中的一列添加DateTimePicker控件如何在一个DataGridView中的一列上添加DateTimePic

如何在一个DataGridView中的一列添加DateTimePicker控件
如何在一个DataGridView中的一列上添加DateTimePicker控件,

[解决办法]
这个要自定义了,可能用到如下的几个类:
从DataGridViewColumn继承一个新的列类型
从DataGridViewCell继承一个新的单元类型.
从DateTimePicker, IDataGridViewEditingControl继承新的DateTimePicker控件,

[解决办法]
你建个组件类,下面是源码,自已再贴上去

public class CalendarColumn : DataGridViewColumn
{

private bool showUpDown = true;

public bool ShowUpDown
{
get
{
return showUpDown;
}
set
{
showUpDown = value;
}
}

public CalendarColumn()
: base(new CalendarCell())
{
}

public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{

if (value != null &&
!value.GetType().IsAssignableFrom(typeof(CalendarCell)))
{
throw new InvalidCastException( "Must be a CalendarCell ");
}
base.CellTemplate = value;
}
}

private void InitializeComponent()
{

}
}

热点排行