自定义控件 之 树型控件
2008-01-28 19:05
183 查看
要过年了,自己却要离开这个地方了....想着没什么好留下的...打算花一个周的时间..编写个树控件出来.留给公司吧.....也顺便学学编写控件.....
介绍:
前段时间, 做移动集团综合告警的时候,由于要实时的显示现有告警,所以,有开发过一个树控件,支持了结点的动态生成....但是,由于针对性太强,不能够得到复用,以至经理要求做一个新的树型控件出来,因此,也就有了这篇文章...
废话:
由于是第一次弄这样的东西,如果有什么不正确的地方,还希望各个老大帮忙指出....
第一步:编写一个容器控件ContentControl..
问题描述:
是从Control派生,还是从UserControl派生,且,是否支持用户使用本控件后,在vs ide 中可以直接拖控件到该控件中.....
解决方法:由于编写该控件的目的,是自定一个树控件,因此,没必要支持把别的控件拖动到本控件中....如果实在是要支持这样的,可以这样设置...
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design")]
public class ContentControl : Control
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace BOCO.Controls
第三步:正如上面看到的,TreeItem,这个东西是什么?TreeItem,表示的是树节点的tag,同时,也是一个逻辑上的树(好了,难点来了)
首先,怎么设计这个逻辑意义上的树..
树节点,一般有两种形式,一是叶子节点,二是树枝节点(不知道组合模式可不可以用到这个地方)
树叶子节点接口:IChild<T>(因为在看范型的东西,所以,使用下下)
public interface IChild<T> where T: class, IChild<T>
树树枝节点接口:
using System;
using System.Collections.Generic;
using System.Text;
namespace BOCO.Controls
如上,CollectionList是什么东西呢?这个是实现接口IBindingList的东西,那IBindingList这个又是什么呢?好象是实现了这个接口的,就可以在后台模型更改后,反映到前台来的吧.....
(未完....)
第四步:节点事件的参数:TreeNodeEventArgs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace BOCO.Controls
第五步:TreeControl,继承ContentControl,实现ITreeControl接口
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace BOCO.Controls
第六步:树节点的层次应支持可配置
未完....明天继续....
介绍:
前段时间, 做移动集团综合告警的时候,由于要实时的显示现有告警,所以,有开发过一个树控件,支持了结点的动态生成....但是,由于针对性太强,不能够得到复用,以至经理要求做一个新的树型控件出来,因此,也就有了这篇文章...
废话:
由于是第一次弄这样的东西,如果有什么不正确的地方,还希望各个老大帮忙指出....
第一步:编写一个容器控件ContentControl..
问题描述:
是从Control派生,还是从UserControl派生,且,是否支持用户使用本控件后,在vs ide 中可以直接拖控件到该控件中.....
解决方法:由于编写该控件的目的,是自定一个树控件,因此,没必要支持把别的控件拖动到本控件中....如果实在是要支持这样的,可以这样设置...
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design")]
public class ContentControl : Control
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace BOCO.Controls
第三步:正如上面看到的,TreeItem,这个东西是什么?TreeItem,表示的是树节点的tag,同时,也是一个逻辑上的树(好了,难点来了)
首先,怎么设计这个逻辑意义上的树..
树节点,一般有两种形式,一是叶子节点,二是树枝节点(不知道组合模式可不可以用到这个地方)
树叶子节点接口:IChild<T>(因为在看范型的东西,所以,使用下下)
public interface IChild<T> where T: class, IChild<T>
树树枝节点接口:
using System;
using System.Collections.Generic;
using System.Text;
namespace BOCO.Controls
如上,CollectionList是什么东西呢?这个是实现接口IBindingList的东西,那IBindingList这个又是什么呢?好象是实现了这个接口的,就可以在后台模型更改后,反映到前台来的吧.....
(未完....)
第四步:节点事件的参数:TreeNodeEventArgs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace BOCO.Controls
第五步:TreeControl,继承ContentControl,实现ITreeControl接口
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace BOCO.Controls
第六步:树节点的层次应支持可配置
未完....明天继续....
相关文章推荐
- 自定义控件之带有树型控件的下拉列表框
- 自定义控件之节点为下拉列表框的树型控件
- ASP.NET自定义控件――CheckBoxList控件
- Winform自定义控件之复合控件开发
- 用户控件和自定义控件的区别
- 【ASP.NET】用户控件和自定义控件的主要区别
- [iOS 自定义控件] LFFExcelView 自定义excel表格的控件
- c# 自定义控件 属性菜单 控件移动 闪烁
- VC中实现带有背景位图的树型控件
- Android编写自定义控件 开关控件
- 用户控件和自定义控件的定义及区别
- Android绘图机制(六)自定义控件之组合控件
- WPF自定义控件,将该控件中包含的控件的某个属性绑定到自定义的属性对外暴露
- Web 用户控件与 Web 自定义控件
- 自定义控件三部曲之绘图篇(十六)——给控件添加阴影效果与发光效果
- c#创建自定义控件在winform上添加该控件属性为空白
- 自定义控件之空调温度调节控件
- Asp.net 2.0 自定义控件开发[创建自定义浮动菜单FloadMenu控件][示例代码下载]
- Android自定义控件之自定义Text,令控件中的字根据控件高度自动调整大小-FenGKun
- Asp.net 2.0 自定义控件开发[开发一个图表(WebChart)控件(柱状图示例)](示例代码下载)