有人知道如何将新的数据成员添加到checkboxboxlist的子类吗?
我尝试创建自己的窗口小部件, 并试图让datagridview表现出我想要的样子。
后者运气不好,而前者我可能永远都做不完。
这是一个可绑定的复选框,我正尝试对其进行修改以适合我的需求。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Design;
namespace WinformsTest.Controls
{
[ToolboxBitmap(typeof(CheckedListBox))]
public class BindableCheckboxList : CheckedListBox
{
public BindableCheckboxList()
{
this.CheckOnClick = true;
}
[DefaultValue("")]
[TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[Browsable(true)]
[Category("Data")]
public new string DisplayMember
{
get
{
return base.DisplayMember;
}
set
{
base.DisplayMember = value;
}
}
[DefaultValue("")]
[TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[Browsable(true)]
[Category("Data")]
public string CheckedMember
{
get;
set;
}
[DefaultValue("")]
[TypeConverter("System.Windows.Forms.Design.DataMemberFieldConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[Editor("System.Windows.Forms.Design.DataMemberFieldEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[Browsable(true)]
[Category("Data")]
public new string ValueMember
{
get
{
return base.ValueMember;
}
set
{
base.ValueMember = value;
}
}
[DefaultValue("")]
[AttributeProvider(typeof(IListSource))]
[RefreshProperties(RefreshProperties.All)]
[Browsable(true)]
[Category("Data")]
public new object DataSource
{
get
{
return base.DataSource;
}
set
{
base.DataSource = value;
}
}
}
}
请注意,我正在尝试添加CheckedMember
如果数据源有效且可绑定,我希望复选框列表将复选框更新为checkedMember。