DisplayNameAttribute クラス

定義

引数を受け取たないプロパティ、イベント、またはパブリック void メソッドの表示名を指定します。

public ref class DisplayNameAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Property)]
public class DisplayNameAttribute : Attribute
public class DisplayNameAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Event | System.AttributeTargets.Method | System.AttributeTargets.Property)>]
type DisplayNameAttribute = class
    inherit Attribute
type DisplayNameAttribute = class
    inherit Attribute
Public Class DisplayNameAttribute
Inherits Attribute
継承
DisplayNameAttribute
属性

次のコード例では、DisplayNameAttribute クラスを使用して、MisnamedProperty と呼ばれるプロパティの名前をPropertyGrid コントロールのRenamedPropertyに変更する方法を示します。 完全なコード一覧については、「方法: Windows Forms コントロールで属性を適用するを参照してください。

// This property exists only to demonstrate the
// DisplayName attribute. When this control
// is attached to a PropertyGrid control, the
// property will appear as "RenamedProperty"
// instead of "MisnamedProperty".
[Description("Demonstrates DisplayNameAttribute.")]
[DisplayName("RenamedProperty")]
public bool MisnamedProperty => true;
' This property exists only to demonstrate the 
' DisplayName attribute. When this control 
' is attached to a PropertyGrid control, the
' property will be appear as "RenamedProperty"
' instead of "MisnamedProperty".
<Description("Demonstrates DisplayNameAttribute."), _
DisplayName("RenamedProperty")> _
Public ReadOnly Property MisnamedProperty() As Boolean
    Get
        Return True
    End Get
End Property

注釈

既定値は、プロパティまたはイベントの名前です。 GetSortedActionItemsの既定の実装では、リフレクションを使用して、引数を受け取っていないパブリック プロパティとパブリック void メソッドを検索します。 GetSortedActionItems は、各プロパティとメソッドの DisplayNameAttribute を検索し、見つかった場合は、プロパティ名またはメソッド名の代わりにその文字列を使用します。

コンストラクター

名前 説明
DisplayNameAttribute()

DisplayNameAttribute クラスの新しいインスタンスを初期化します。

DisplayNameAttribute(String)

表示名を使用して、 DisplayNameAttribute クラスの新しいインスタンスを初期化します。

フィールド

名前 説明
Default

DisplayNameAttributeの既定値を指定します。 このフィールドは読み取り専用です。

プロパティ

名前 説明
DisplayName

この属性に格納されている引数を受け取っていないプロパティ、イベント、またはパブリック void メソッドの表示名を取得します。

DisplayNameValue

表示名を取得または設定します。

TypeId

派生クラスで実装されている場合は、この Attributeの一意の識別子を取得します。

(継承元 Attribute)

メソッド

名前 説明
Equals(Object)

2 つの DisplayNameAttribute インスタンスが等しいかどうかを判断します。

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)

適用対象

こちらもご覧ください