比较复杂。慢慢看。//集合成员类如下格式声明 [ToolboxItem(false)]//设置此类在工具箱中不可见 [DesignTimeVisible(false)]//设置设计时此类不可见 public class BarItem:Component//必需以Component类为基类 { }//集合类定义如下 public class BarItemCollection:CollectionBase//从集合基类继承 { //必需要实现的索引 public BarItem this[int index] { get{}; set{}; } //可不实现 public void AddRange(BarItem[] bars) { } } //控件类定交如下 public class ListBar:UserControl { private BarItemCollection baritems; [Browsable(true)]//设计时可见 [Editor(typeof(CollectionEdit),typeof(UITypeEditor)]//设置设计时编辑集合的编辑器 [DesignerSerializationVisibility(DesignerSerialization.Content)]//设置设计器是序列化它的内容。 public BarItemCollection BarCollections { get {} set {} } } 以上所有类都是你自实现。可能有部分单词拼错了。可查MSDN 这不是偶写的啊。
public StringCollection fieldList
{
set
{
FieldList = value;
}
get
{
return FieldList;
}
}
加上new stringcollection()效果是一样的。
那位高人出来指点一下吧!拜托再拜托!
[ToolboxItem(false)]//设置此类在工具箱中不可见
[DesignTimeVisible(false)]//设置设计时此类不可见
public class BarItem:Component//必需以Component类为基类
{
}//集合类定义如下
public class BarItemCollection:CollectionBase//从集合基类继承
{
//必需要实现的索引
public BarItem this[int index]
{
get{};
set{};
}
//可不实现
public void AddRange(BarItem[] bars)
{
}
}
//控件类定交如下
public class ListBar:UserControl
{
private BarItemCollection baritems;
[Browsable(true)]//设计时可见
[Editor(typeof(CollectionEdit),typeof(UITypeEditor)]//设置设计时编辑集合的编辑器
[DesignerSerializationVisibility(DesignerSerialization.Content)]//设置设计器是序列化它的内容。
public BarItemCollection BarCollections
{
get
{}
set
{}
}
}
以上所有类都是你自实现。可能有部分单词拼错了。可查MSDN
这不是偶写的啊。