比较复杂。慢慢看。//集合成员类如下格式声明 [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
大多数的方法都是保存成一个文件,例如Xml格式的文件。
是啊,我自已定义属性编辑器.通过继承Form
不知道是否是在集合属性中使用属性还是重写UITypeEditor的PaintValue或其它函数
我看过ToolBar中的ToolBarButton。当增加toolbarbutton时。它会自动加入代码.
我也已经弄了好久了,和楼主结果一样.
看看这个,这是我今天刚翻到的,共同学习
[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
1。保存到一个INI文件中;
2。保存到注册表中;
3。保存在一个数据库中。