昨天晚上写了基础篇,有朋友说写的太简单,我想在这里申明下:因为我要写组件编程的完整系列,所以从最简单的开始写起,而且园子里有很多的朋友可能从来都没有写组件的经历,在这里希望有组件开发经验的朋友能多多包涵。
        前一章,我们创建了最简单的组件,今天讲讲Component的PropertyAttribute和EventAttribute。
        EventAttribute有:
                BrowsableAttribute 、CategoryAttribute、DescriptionAttribute、DefaultEventAttribute
        PropertyAttribute有:
                BrowsableAttribute 、CategoryAttribute、DescriptionAttribute、DefaultPropertyAttribute、DefaultValueAttribute、EditorAttribute
、DesignerSerializationVisibilityAttribute、TypeConverterAttribute、BindableAttribute、LocalizableAttribute
       
        在本章教程中我们主要讲以上红色的Attribute,再下章的Designer UI会讲蓝色的Attribute,紫色的Attribute不作讲解。
     上述的Attribute简明阐述如下:
             BrowsableAttribute:在Property窗口中是否可见。
             CategoryAttribute:Property或者Event所属的哪个组。
             DescriptionAttribute:Property或者Event的简单描述。
             DefaultEventAttribute:默认Event、。
             DefaultPropertyAttribute:默认Property,选中组件,其Property窗口中默认选中在这个Property上。
             DefaultValueAttribute:Property的默认值,选中组件,其Event窗口中默认选中在这个Event上。

.NET组件编程(2) PropertyAttribute和EventAttributeusing System;
.NET组件编程(2) PropertyAttribute和EventAttribute
using System.Collections.Generic;
.NET组件编程(2) PropertyAttribute和EventAttribute
using System.Text;
.NET组件编程(2) PropertyAttribute和EventAttribute
using System.ComponentModel;
.NET组件编程(2) PropertyAttribute和EventAttribute
.NET组件编程(2) PropertyAttribute和EventAttribute
namespace Components

其Property、Event窗口如下:

.NET组件编程(2) PropertyAttribute和EventAttribute.NET组件编程(2) PropertyAttribute和EventAttribute

我原来没有用过DefaultValueAttribute,上面代码中的Address、Age在Customer1创建时没有得到DefaultValue,我会找出原因,并在下章补上,也希望知道的朋友能告之。

相关文章:

  • 2021-09-22
  • 2021-10-10
  • 2021-05-09
  • 2022-01-21
  • 2021-07-18
猜你喜欢
  • 2021-05-19
  • 2021-08-04
  • 2021-10-14
  • 2021-07-28
相关资源
相似解决方案