PropertyGird 控件的简单用法
2010-12-15 18:00
357 查看
PropertyGird 控件 , 我想大多数朋友都不陌生 , 因为 Visual Studio 里对属性的操作就是通过 PropertyGird 控件来实现的.
PropertyGird - 常用属性 :
1. SelectedObject
通俗的讲 SelectedObject 属性就是用来指定对象的 ;
如果是在对象列表中则是指定的列表中的第一个对象 ;
如果当前没有选定任何对象 , 返回值则为 " 空引用 " (在 Visual Basic 中为 Nothing).
使用语法 :
比如我有一个 Car 类.
PropertyGrid.SelectedObject = new Car;
2. 属性的分组
CategoryAttribute 类.
PropertyGird - 常用属性 :
1. SelectedObject
通俗的讲 SelectedObject 属性就是用来指定对象的 ;
如果是在对象列表中则是指定的列表中的第一个对象 ;
如果当前没有选定任何对象 , 返回值则为 " 空引用 " (在 Visual Basic 中为 Nothing).
使用语法 :
比如我有一个 Car 类.
PropertyGrid.SelectedObject = new Car;
2. 属性的分组
CategoryAttribute 类.
指定当属性 (Property) 或事件显示在一个设置为 " 按分类顺序 " 模式的 PropertyGrid 控件中时 , 用于给属性或事件分组的类别的名称.
[CategoryAttribute("分组的名称")] - 使用这样的格式在属性的上方来进行属性的分组.
使用方法 :
public class Car { private Color black; [CategoryAttribute("外观")] private Color Black { get { return this.black; } set { this.black = value; } } }
3. 属性的值状态
ReadOnlyAttribute 类.
指定该属性 (Attribute) 所绑定到的属性 (Property) 在设计时是只读属性 (Property) 还是读/写属性 (Property) .无法继承此类.
[ReadOnlyAttribute (true)] - 使用这样的格式在属性的上方来进行属性的只读进行控制.( 值 [True & False] )
使用方法 :
public class Car { private Color black; [ReadOnlyAttribute(true)] private Color Black { get { return this.black; } set { this.black = value; } } }
4. 设置属性的帮助说明
Description .
指定当选中该属性时控件下方的帮助说明文字.
[Description("颜色的设置")] - 使用这样的格式在属性的上方来进行属性的说明的输出.
使用方法 :
public class Car { private Color black; [Description("颜色的设置")] private Color Black { get { return this.black; } set { this.black = value; } } }
设置的多项时 , 使用逗号隔开.
public class Car { private Color black; [CategoryAttribute("外观"), ReadOnlyAttribute(true), Description("颜色的设置")] private Color Black { get { return this.black; } set { this.black = value; } } }
相关文章推荐
- Report Machine(RM)报表控件简单用法-delphi
- Struts2中对数据简单的验证和property标签的用法
- VC++6控件简单用法总结
- |CTreeCtrl树控件的简单用法|
- VS2008 串口控件 MSCOMM 用法变了,更简单了
- 控件的简单用法
- Jquery回顾一些input控件的简单用法
- MFC 之 RADIO控件 简单用法
- 时间控件My97简单用法
- ASP.net 中的AJAX学习记录之四 updateProgress控件的简单用法
- 【Android成长之路】最常用和最难用的控件——ListView的浅谈(ListView 的简单用法)
- Report Machine(RM)报表控件简单用法-delphi
- MFC中CImageList(图形列表控件)和CTreeCtrl(树形列表控件)的简单用法
- ASP.net 中的AJAX学习记录之四 updateProgress控件的简单用法
- AndroidSlidingUpPanel控件的用法以及简单解析
- WinForm中BackgroundWorker控件用法简单实例
- My97DatePicker日期控件简单用法
- sencha-touch2.0控件nestlist的简单用法
- UIKit:switch和slider控件的简单用法
- Android 开源控件的简单用法(不定时更新)