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 プロパティの名前を RenamedProperty 変更する方法を PropertyGrid 示します。 完全なコード一覧については、「方法: Windows フォーム コントロールで属性を適用する」を参照してください。

// 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
{
    get
    {
        return 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()

この属性が既定値かどうかを判断します。

IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
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)

適用対象

こちらもご覧ください