指定在其中进行分组的属性或事件中显示的类别的名称 控件设置为按分类顺序模式。
命名空间:
程序集: System(位于 System.dll)System.ComponentModel.CategoryAttribute
[AttributeUsageAttribute(AttributeTargets.All)]public class CategoryAttribute : Attribute
名称 | 说明 | |
---|---|---|
新实例初始化 CategoryAttribute 类使用的类别名称默认值。 | ||
新实例初始化 CategoryAttribute 类使用指定的类别名称。 |
名称 | 说明 | |
---|---|---|
获取 CategoryAttribute 表示的操作类别。 | ||
获取 CategoryAttribute 表示外观类别。 | ||
获取 CategoryAttribute 表示异步类别。 | ||
获取 CategoryAttribute 表示行为类别。 | ||
获取的属性或此特性应用于事件的类别的名称。 | ||
获取 CategoryAttribute 表示数据类别。 | ||
获取 CategoryAttribute 表示默认类别。 | ||
获取 CategoryAttribute 表示设计类别。 | ||
获取 CategoryAttribute 表示拖放类别。 | ||
获取 CategoryAttribute 表示焦点类别。 | ||
获取 CategoryAttribute 表示格式类别。 | ||
获取 CategoryAttribute 表示键类别。 | ||
获取 CategoryAttribute 表示布局类别。 | ||
获取 CategoryAttribute 表示鼠标类别。 | ||
在派生类中实现时,获取此 的唯一标识符。(继承自 。) | ||
获取 CategoryAttribute 表示 WindowStyle 类别。 |
名称 | 说明 | |
---|---|---|
返回给定对象的值是否等于当前 CategoryAttribute...(覆盖 。) | ||
在垃圾回收将某一对象回收前允许该对象尝试释放资源并执行其他清理操作。(继承自 。) | ||
返回此属性的哈希代码。(覆盖 。) | ||
查找指定类别的本地化名称。 | ||
获取当前实例的 。(继承自 。) | ||
确定此属性是否为默认值。(覆盖 。) | ||
当在派生类中重写时返回一个值,该值指示此实例是否等于指定的对象。(继承自 。) | ||
创建当前 的浅表副本。(继承自 。) | ||
返回表示当前对象的字符串。(继承自 。) |
名称 | 说明 | |
---|---|---|
将一组名称映射为对应的一组调度标识符。(继承自 。) | ||
检索对象的类型信息,然后可以使用该信息获取接口的类型信息。(继承自 。) | ||
检索对象提供的类型信息接口的数量(0 或 1)。(继承自 。) | ||
提供对某一对象公开的属性和方法的访问。(继承自 。) |
一个 CategoryAttribute 表示将关联的属性或事件,相关联的类别列出属性或中的事件时 控件设置为 模式。 如果 CategoryAttribute 尚未应用到属性或事件时, 将其与相关联 杂项 类别。 可以通过指定的类别名称的构造函数中的任何名称创建新类别 CategoryAttribute。
属性指示该属性表示类别的名称。 属性还提供了透明本地化的类别名称。
继承函数说明:
如果您使用预定义的名称以外的类别名称,并且您想要本地化类别名称,必须重写 方法。
CategoryAttribute 类定义了以下常见类别︰
类别 | 描述 |
---|---|
可用操作与相关的属性。 | |
与实体的显示方式相关的属性。 | |
与实体的行为相关的属性。 | |
对数据和数据源管理相关的属性。 | |
在默认类别中的分组的属性。 | |
只能在设计时是可用的属性。 | |
与拖放操作相关的属性。 | |
重点介绍相关的属性。 | |
对格式设置相关的属性。 | |
与键盘相关的属性。 | |
为布局相关的属性。 | |
鼠标与相关的属性。 | |
为顶层窗体的窗口样式相关的属性。 |
下面的示例创建 MyImage 属性。 该属性具有两个属性︰ 和 CategoryAttribute。
[Description("The p_w_picpath associated with the control"),Category("Appearance")] public Image MyImage { get { // Insert code here. return p_w_picpath1; } set { // Insert code here. } }
下一个示例获取的类别 MyImage。 首先,此代码可获取 的对象的所有属性。 接下来,代码索引 获取 MyImage。 然后它将返回此属性的属性,并将它们保存在变量中 attributes。
该示例然后通过检索输出类别 CategoryAttribute 从 , ,并将它写入到控制台屏幕。
// Gets the attributes for the property. AttributeCollection attributes = TypeDescriptor.GetProperties(this)["MyImage"].Attributes; // Prints the description by retrieving the CategoryAttribute. // from the AttributeCollection. CategoryAttribute myAttribute = (CategoryAttribute)attributes[typeof(CategoryAttribute)]; Console.WriteLine(myAttribute.Category);
备注:转自