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 類別來指定 coNtext 關鍵字。 如需此程式碼範例的完整說明,請參閱How to: Apply Attributes in Windows Forms 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

備註

根據預設,類別的 Type.FullName Help 關鍵字是由 屬性值所指定。 對於成員,Help 關鍵字是由宣告屬性之型別的完整名稱所指定,加上屬性名稱本身。

例如,請考慮 Control.Text 控制項上的 System.Windows.Forms.Button 屬性。 class 關鍵字為 「System。Windows。Forms.Button「,但 Control.Text property 關鍵字為 」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 指定的字串。 這不會用於有問題的型別成員,這仍會反映宣告型別的實際完整名稱加上成員名稱。 此屬性支援具有相關聯通用檔但不同說明識別碼的強型別類別。

建構函式

HelpKeywordAttribute()

初始化 HelpKeywordAttribute 類別的新執行個體。

HelpKeywordAttribute(String)

初始化 HelpKeywordAttribute 類別的新執行個體。

HelpKeywordAttribute(Type)

初始化指定型別之 HelpKeywordAttribute 類別的新執行個體。

欄位

Default

表示 HelpKeywordAttribute 的預設值。 此欄位為唯讀。

屬性

HelpKeyword

取得這個屬性提供的說明關鍵字。

TypeId

在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。

(繼承來源 Attribute)

方法

Equals(Object)

判斷兩個 HelpKeywordAttribute 執行個體是否相等。

GetHashCode()

傳回這個執行個體的雜湊碼。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IsDefaultAttribute()

判斷 Help 關鍵字是否為 null

Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

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

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。

(繼承來源 Attribute)

適用於