HelpKeywordAttribute 类

定义

为类或成员指定上下文关键字。 此类不能被继承。

public ref class HelpKeywordAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=false, Inherited=false)]
public sealed class HelpKeywordAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=false, Inherited=false)]
[System.Serializable]
public sealed class HelpKeywordAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=false, Inherited=false)>]
type HelpKeywordAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=false, Inherited=false)>]
[<System.Serializable>]
type HelpKeywordAttribute = class
    inherit Attribute
Public NotInheritable Class HelpKeywordAttribute
Inherits Attribute
继承
HelpKeywordAttribute
属性

示例

下面的代码示例演示如何通过在成员本身上放置属性来替代此帮助系统行为。 以下是以下类的关键字,称为 DemoComponent

  • 类关键字:“System.ComponentModel.Component” (DemoNamespace.DemoComponent)

  • Property1 关键字:“DemoNamespace.DemoComponent.Property1” (默认)

  • Property2 关键字:“SomeNamespace.SomeOtherClass.Property2” (DemoNamespace.DemoComponent.Property2)

[HelpKeywordAttribute(typeof(Component))]  
public class DemoComponent : Component  
{  
    public string Property1  
    {  
        get  
        {  
            return "";  
        }  
    }  

    [HelpKeywordAttribute("SomeNamespace.SomeOtherClass.Property2")]  
    public string Property2  
    {  
        get  
        {  
            return "";  
        }  
    }  
}  

下面的代码示例演示如何使用 HelpKeywordAttribute 类来指定上下文关键字。 有关此代码示例的完整说明,请参阅 How to: Apply Attributes in Windows 窗体 Controls

// This control demonstrates a simple logging capability. 
[ComplexBindingProperties("DataSource", "DataMember")]
[DefaultBindingProperty("TitleText")]
[DefaultEvent("ThresholdExceeded")]
[DefaultProperty("Threshold")]
[HelpKeywordAttribute(typeof(UserControl))]
[ToolboxItem("System.Windows.Forms.Design.AutoSizeToolboxItem,System.Design")]
public class AttributesDemoControl : UserControl
{
' This control demonstrates a simple logging capability. 
<ComplexBindingProperties("DataSource", "DataMember"), _
DefaultBindingProperty("TitleText"), _
DefaultEvent("ThresholdExceeded"), _
DefaultProperty("Threshold"), _
HelpKeywordAttribute(GetType(UserControl)), _
ToolboxItem("System.Windows.Forms.Design.AutoSizeToolboxItem,System.Design")> _
Public Class AttributesDemoControl
    Inherits UserControl

注解

默认情况下,类的 Help 关键字由 Type.FullName 属性值提供。 对于成员,Help 关键字由声明属性的类型的完整名称以及属性名称本身提供。

例如,请考虑 Control.Text 控件上的 System.Windows.Forms.Button 属性。 类关键字为“System”。Windows。Forms.Button“,但Control.Text属性关键字为”System.Windows。Forms.Control.Text“,因为属性Control.Text是在类上System.Windows.Forms.Control声明的,而不是System.Windows.Forms.Button类本身;类System.Windows.Forms.Button继承该属性。

相比之下,该Button.DialogResult属性在类上System.Windows.Forms.Button声明,因此其关键字为“System.Windows。Forms.Button.DialogResult”。

当帮助系统获取关键字时,它将首先查看 HelpKeywordAttribute。 在类级别,它将返回由该 HelpKeywordAttribute字符串指定的字符串。 这不会用于有问题的类型的成员,这仍将反映声明类型的实际全名,以及成员名称。 此属性支持具有关联常见文档但不同帮助 ID 的强类型类。

构造函数

HelpKeywordAttribute()

初始化 HelpKeywordAttribute 类的新实例。

HelpKeywordAttribute(String)

初始化 HelpKeywordAttribute 类的新实例。

HelpKeywordAttribute(Type)

初始化给定类型的 HelpKeywordAttribute 类的新实例。

字段

Default

表示 HelpKeywordAttribute 的默认值。 此字段为只读。

属性

HelpKeyword

获取此属性提供的帮助关键字。

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。

(继承自 Attribute)

方法

Equals(Object)

确定两个 HelpKeywordAttribute 实例是否相等。

GetHashCode()

返回此实例的哈希代码。

GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

确定“帮助”关键字是否为 null

Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。

(继承自 Attribute)

适用于