最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
自定义组件之属性(Property)的性质(Attribute)介绍(四)
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
这里的属性编辑器的意思是能够实现上面提到的弹出对话框和下拉UI的形式。废话不说下面我们一一介绍。
1、 弹出对话框的形式
在本例中我使用了string类型的属性来显示版本的信息,大家可以随便的写各类的属性,这里只需要指定改属性的编辑器就可以了。
首先我们要建立一个string类型的属性,代码如下:
private string _appVer="1.0";
[CategoryAttribute("自定义编辑器"),
DefaultValueAttribute("1.0"),
DescriptionAttribute("版本信息"),
ReadOnlyAttribute(true),
EditorAttribute(typeof(AppVerConverter),typeof(System.Drawing.Design.UITypeEditor))]
public string AppVer
{
get {return this._appVer;}
set {this._appVer=value;}
}
大家可能已经注意到了在这个属性之多出了一个性质EditorAttribute(typeof(AppVerConverter),typeof(System.Drawing.Design.UITypeEditor)),具体的意思大家可以参考MSDN我在这里就不用多说了,那么我们看看AppVerConverter这个类是怎么实现的就可以了。具体代码如下:
///
/// 自定义UI的属性编辑器(弹出消息)
///
public class AppVerConverter:System.Drawing.Design.UITypeEditor
{
///
/// 覆盖此方法以返回编辑器的类型。
///
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
-
上一个: 控件代码共享--日期选择控件
-
下一个: 用C#创建COM对象(转自计算机世界)
相关文章
- ppt自定义尺寸 07-02
- ps如何添加自定义形状 07-02
- Tiki如何自定义添加个性贴 06-18
- ps图案和画笔预设怎么自定义 有什么作用 06-14
- AI参考线如何自定义颜色 06-14
- Vue自定义指令拖拽功能示例 04-13