Class Design: 一些有用的Attribute
2010-09-14 16:34
330 查看
[Description("Dampingcalculationmethod"),CategoryAttribute("Generalpropellerdata")] [TypeConverter(typeof(OptionConverter))] [Range(0.0,1.0,ErrorMessage="PitchRatiomustbebetween0and1")] [ReadOnly(false)] [Browsable(false)] [EditorBrowsable(EditorBrowsableState.Never)]
publicdoublePitchRatio{get;set;}
[Range(1,5,ErrorMessage="PitchRatiomustbebetween1and5")][ReadOnly(false)][Browsable(false)][EditorBrowsable(EditorBrowsableState.Never)]
publicintPitchRatio{get;set;}
1)PropertyGridDataBinding支持/Array显示为Combox
[TypeConverter(typeof(OptionConverter))]
publicclassOptionConverter:StringConverter{publicstaticreadonlystring[]DampingModel={"Dynamicmagnifier","Schwanecke","Archer","Frahm"};publicoverrideTypeConverter.StandardValuesCollectionGetStandardValues(ITypeDescriptorContextcontext){returnnewStandardValuesCollection(DampingModel);}publicoverrideboolGetStandardValuesExclusive(ITypeDescriptorContextcontext){returntrue;//TruemakestheComboboxselectonly.Falseallowsfreetextentry.}publicoverrideboolGetStandardValuesSupported(ITypeDescriptorContextcontext){returntrue;//TruetellsthePropertyGridtodisplayaCombobox}}
2)Range
对于double,要用[Range(0.0,1.0,ErrorMessage="PitchRatiomustbebetween0.0and1.0")]
如果用[Range(0,1,ErrorMessage="PitchRatiomustbebetween0.0and1.0")],则失效。
类型的准确。
3)[Browsable(false)] 指定一个属性或事件是否应显示在“属性”窗口中。
4)[EditorBrowsable(EditorBrowsableState.Never)] 指定某个属性或方法在编辑器中可以查看.
例如,VisualStudio中的IntelliSense引擎使用此特性来确定是否显示属性或方法。
自己定义显示AutoCompletionList;
5)[ReadOnly(false)],Description("Dampingcalculationmethod"),CategoryAttribute("Generalpropellerdata")]
相关文章推荐
- 一些比较有用的js脚本--通过class改变css样式
- SQLAnywhere一些有用的工具
- 我是学习 “软件工程” 专业的一名 本科生,请问考一些跟 编程 有关的证书面试的时候有用吗? 用处大吗?
- Shell脚本一些有用且很酷的东西
- Modern C++ Design 学习笔记之Policy Based Class Design
- SQL Anywhere教程(八):一些有用的工具(Part I)
- 手机音视频流媒体开发一些有用资料
- Absent Code attribute in method that is not native or abstract in class file javax/mail/Session 解决方式
- 一些有用的网络工具
- 一些有用的linux命令
- Failed to load Main-Class manifest attribute from
- Android 软件开发时用到的一些有用软件列表
- C++11 的一些有用的特性1 VS2012可支持
- 关于 Portal 一些有用的网址
- 一些有用的文章链接
- java(jsp) 学习过程中 一些有用的链接
- PM的自我修养——关于AndroidDesign的一些基础知识
- 【Java Tips] 一些有用的转换方法
- 处理时间的一些有用的方法
- #include #import @class 的一些用法区别