DesignOnlyAttribute クラス

定義

プロパティを設定できるのがデザイン時だけかどうかを指定します。

public ref class DesignOnlyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class DesignOnlyAttribute : Attribute
public sealed class DesignOnlyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type DesignOnlyAttribute = class
    inherit Attribute
type DesignOnlyAttribute = class
    inherit Attribute
Public NotInheritable Class DesignOnlyAttribute
Inherits Attribute
継承
DesignOnlyAttribute
属性

次の例では、 プロパティを GetLanguage 作成します。 プロパティは でマークされます DesignOnlyAttribute

public:
   [DesignOnly(true)]
   property CultureInfo^ GetLanguage 
   {
      CultureInfo^ get()
      {
         // Insert code here.
         return myCultureInfo;
      }
      void set( CultureInfo^ value )
      {
         // Insert code here.
      }
   }
[DesignOnly(true)]
 public CultureInfo GetLanguage {
    get {
       // Insert code here.
       return myCultureInfo;
    }
    set {
       // Insert code here.
    }
 }
<DesignOnly(True)> _
Public Property GetLanguage() As CultureInfo
    Get
        ' Insert code here.
        Return myCultureInfo
    End Get
    Set
        ' Insert code here.
    End Set
End Property

次の例では、 の値を取得します DesignOnlyAttribute。 最初に、コードは オブジェクトのすべてのプロパティを持つ を取得 PropertyDescriptorCollection します。 次に、 に PropertyDescriptorCollection インデックスを作成して プロパティを GetLanguage 見つけます。 次に、このプロパティの属性を返し、それらを attributes 変数に保存します。

次に、 から を取得DesignOnlyAttributeAttributeCollectionし、コンソール画面に書き込むだけで、 プロパティがデザインされているかどうかを出力します。

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "GetLanguage" ]->Attributes;

/* Prints whether the property is marked as DesignOnly 
by retrieving the DesignOnlyAttribute from the AttributeCollection. */
DesignOnlyAttribute^ myAttribute = dynamic_cast<DesignOnlyAttribute^>(attributes[ DesignOnlyAttribute::typeid ]);
Console::WriteLine( "This property is design only :{0}", myAttribute->IsDesignOnly );
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["GetLanguage"].Attributes;

 /* Prints whether the property is marked as DesignOnly 
  * by retrieving the DesignOnlyAttribute from the AttributeCollection. */
 DesignOnlyAttribute myAttribute = 
    (DesignOnlyAttribute)attributes[typeof(DesignOnlyAttribute)];
 Console.WriteLine("This property is design only :" +
    myAttribute.IsDesignOnly.ToString());
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("GetLanguage").Attributes

' Prints whether the property is marked as DesignOnly 
' by retrieving the DesignOnlyAttribute from the AttributeCollection.
Dim myAttribute As DesignOnlyAttribute = _
    CType(attributes(GetType(DesignOnlyAttribute)), DesignOnlyAttribute)
Console.WriteLine(("This property is design only :" & _
    myAttribute.IsDesignOnly.ToString()))

注釈

に設定trueされたDesignOnlyAttributeメンバーは、デザイン時にのみ設定できます。 通常、これらのプロパティはデザイン時にのみ存在し、実行時のオブジェクトの実際のプロパティには対応しません。

属性を持たないメンバー、または が にfalse設定されているメンバーはDesignOnlyAttribute、実行時に設定できます。 既定値は、false です。

DesignOnlyAttributetrue 設定されているプロパティの値は、 メソッドではなく .resx ファイルに InitializeComponent シリアル化されます。

詳細については、「属性」を参照してください。

コンストラクター

DesignOnlyAttribute(Boolean)

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

フィールド

Default

DesignOnlyAttribute の既定値 (No) を指定します。 static フィールドは読み取り専用です。

No

プロパティをデザイン時に設定できるか、または実行時に設定できるかを指定します。 static フィールドは読み取り専用です。

Yes

プロパティを設定できるのがデザイン時だけであることを指定します。 static フィールドは読み取り専用です。

プロパティ

IsDesignOnly

プロパティを設定できるのがデザイン時だけかどうかを示す値を取得します。

TypeId

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

(継承元 Attribute)

メソッド

Equals(Object)

指定したオブジェクトの値が現在の DesignOnlyAttribute と等しいかどうかを示す値を返します。

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)

適用対象

こちらもご覧ください