集合编辑器,留着研究下。
来源:互联网 发布:淘宝网购十字绣 编辑:程序博客网 时间:2024/06/14 01:03
最近研究自定义的控件,CollectionBase 真的是很好的东西,效果图如下
其中包括很多经典代码:怎么给List命名?怎么写name的重复报警等?怎么通过index或name找list等
部分代码网上找到,部分代码自己编写,总之还算完善,愿结识喜欢做控件的朋友共同探讨之~~
public class FieldItems : CollectionBase
{
public FieldItems(PxAutoGenTxtPanel _pxAutoGenTxtPanel)
: base()
{
//
// TODO: 在此处添加构造函数逻辑
pxAutoGenTxtPanel = _pxAutoGenTxtPanel;
//
}
private PxAutoGenTxtPanel pxAutoGenTxtPanel = null;
PublicClass pubClass = new PublicClass();
public FieldItem this[int index]
{
get
{
return (FieldItem)base.List[index];
}
set
{
base.List[index] = value;
//this[index].FieldItems = this;
//this[index].PxAutoGenTxtPanel = pxAutoGenTxtPanel;
//this[index].Index = index;
}
}
public FieldItem this[string name]
{
get
{
foreach (FieldItem fI in this)
{
if (fI.Name == name)
{
return fI;
}
}
return null;
}
}
public void Add(FieldItem aItem)
{
base.List.Add(aItem);
}
//public int IndexOf(QueryItem aItem)
//{
// return List.IndexOf(aItem);
//}
public void Remove(int index)
{
if (index < base.Count - 1 && index > 0)
{
base.List.RemoveAt(index);
}
}
protected override void OnInsertComplete(int index, object value)
{
base.OnInsertComplete(index, value);
pubClass.AutoGenTxt(pxAutoGenTxtPanel, this);
}
protected override void OnRemoveComplete(int index, object value)
{
base.OnRemoveComplete(index, value);
pubClass.AutoGenTxt(pxAutoGenTxtPanel, this);
}
protected override void OnSet(int index, object oldValue, object newValue)
{
base.OnSet(index, oldValue, newValue);
pubClass.AutoGenTxt(pxAutoGenTxtPanel, this);
}
}
public class FieldItem
{
public FieldItem()
{
this.Name = "item" + COUNT.ToString();
COUNT++;
}
private static int COUNT = 0;//个数
private string _name; //名称。
PublicClass pubClass = new PublicClass();
private string _lblText = "label";
private FieldItems _fieldItems = null;
private PxAutoGenTxtPanel _pxAutoGenTxtPanel = null;
private int _index = 0;
private static string[] strName = new string[1000] ;
[Category("Label属性"), Description("关键字段名")]
public string LblText
{
get
{
return _lblText;
}
set
{
this._lblText = value;
if (_pxAutoGenTxtPanel != null && _fieldItems != null)
{
pubClass.AutoGenTxt(_pxAutoGenTxtPanel, _fieldItems);
}
}
}
[Category("PX属性"), Description("Item名称")]
public string Name
{
get
{
strName[COUNT] = _name;
return _name;
}
set
{
bool blIsSucc = true;
for (int i = 0; i < strName.Length; i++)
{
if (strName[i] == value)
{
blIsSucc = false;
throw new ArgumentException("集合中的元素不能重名。请修改名称。"+ _name);
}
}
if (blIsSucc == true)
{
_name = value;
}
}
}
#region TextBox属性
private string _txtBoxText = "";
[Category("textBox属性"), Description("TextBox的值")]
public string TxtBoxText
{
get
{
return _txtBoxText;
}
set
{
_txtBoxText = value;
}
}
private bool _txtBoxReadonly = true;
[Category("textBox属性"), Description("TextBox的Readonly属性")]
public bool TxtBoxReadonly
{
get
{
return _txtBoxReadonly;
}
set
{
_txtBoxReadonly = value;
}
}
#endregion
#region 接收父值
public FieldItems FieldItems
{
set
{
_fieldItems = value;
}
}
public PxAutoGenTxtPanel PxAutoGenTxtPanel
{
set
{
_pxAutoGenTxtPanel = value;
}
}
public int Index
{
set
{
_index = value;
}
}
#endregion
}
- 集合编辑器,留着研究下。
- 粒子编辑器研究
- 集合研究------Map
- 各类研究数据集合
- 编辑器、软件、工具集合
- HTML在线编辑器原理研究
- 集合深入研究(1)
- Java研究_JAVA集合类
- Collection 集合框架深入研究
- jdk研究之map集合
- list<Map>集合的研究
- Notepad++文本编辑器资源集合
- CSDN-markdown编辑器icon集合
- java集合(下)_Map集合
- ActionScript2 delegate 研究(下)
- 研究了下正手
- 有空研究下kobject
- Unix下Tuxedo研究
- js去除空格
- 九、建造者模式
- 走在可持续发展之路上的银行
- 使用pscp实现Windows 和 linux服务器间远程拷贝文件
- Struts 2 读书笔记-----使用PreResultListener
- 集合编辑器,留着研究下。
- 这个变压器为什么会烧呢?
- PHP获取访问者IP
- html中嵌套php实现隐藏table中tr
- jQuery ztree 初始化失败
- 黑马程序员——java抽象类详解
- iOS消息推送
- 算法进度
- MTK Widget 开发及Debug介绍