HelpKeywordAttribute 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为类或成员指定上下文关键字。 此类不能被继承。
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 AttributePublic NotInheritable Class HelpKeywordAttribute
Inherits Attribute- 继承
- 属性
示例
下面的代码示例演示如何通过将 属性放置在 成员本身上来替代此帮助系统行为。 这些是以下类的关键字,称为 DemoComponent:
- 类关键字 (keyword) :“ - System.ComponentModel.Component” (- DemoNamespace.DemoComponent)
- Property1 关键字 (keyword) :“” - DemoNamespace.DemoComponent.Property1(默认)
- Property2 关键字 (keyword) :“ - 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 类指定上下文关键字 (keyword) 。 有关此代码示例的完整说明,请参阅如何:在Windows 窗体控件中应用属性。
// 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
注解
默认情况下,类的帮助关键字 (keyword) 由 Type.FullName 属性值提供。 对于成员,帮助关键字 (keyword) 由声明属性的类型的完整名称加上属性名称本身提供。
例如,考虑 Control.Text 控件上的 System.Windows.Forms.Button 属性。 类关键字 (keyword) 为“System.Windows.Forms。Button“,但Control.Text关键字 (keyword) 属性为”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声明,因此其关键字 (keyword) 为“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() | 确定“帮助”关键字是否为  | 
| 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) |