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 這樣做結果是刪除控件後,變量不會刪除
以上代碼希望對你有幫助,,尤其是做這方面的.