
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
using System.ComponentModel.Design;
using Mylib;
namespace MyLib


{
class 动态 : Label

{
private List<TypedFilter> _filters = new List<TypedFilter>();

[Category("BusinessObjectControl")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor(typeof(FilterCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public List<TypedFilter> Filters

{

get
{ return _filters; }

set
{ _filters = value; }
}
}

public class TypedFilter

{
private string _dataPropertyName = "Name";
public string DataPropertyName

{

get
{ return _dataPropertyName; }

set
{ _dataPropertyName = value; }
}

private int _value = 0;
public int Value

{

get
{ return _value; }

set
{ _value = value; }
}

public override string ToString()

{
return _dataPropertyName + " = " + _value.ToString();
}
}

class FilterCollectionEditor : CollectionEditor

{
public FilterCollectionEditor(Type type)
: base(type)

{
}
}
}
其实能实现简单的集合类...还是很多地方不足,,,如果有幸遇到高手还希望帮忙解答...
1.以上的例子只能产生局部变量.不会产生全局的..请问如何解决
我能不能生成,我想要的变量,比如局部,或者全局...
2.public class TypedFilter:Control 这样做结果是删除控件后,变量不会删除
以上代码希望对你有帮助,,尤其是做这方面的.