DesignOnlyAttributeとは? わかりやすく解説

DesignOnlyAttribute クラス

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

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.All)> _
Public NotInheritable Class
 DesignOnlyAttribute
    Inherits Attribute
Dim instance As DesignOnlyAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public sealed class DesignOnlyAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class DesignOnlyAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public final class DesignOnlyAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public final class DesignOnlyAttribute extends
 Attribute
解説解説
使用例使用例

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

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

/** @property 
 */
public void set_GetLanguage(CultureInfo value)
{
    // Insert code here.
} //set_GetLanguage

DesignOnlyAttribute の値を取得する例を次に示します。最初に、オブジェクトのすべてのプロパティを保持する PropertyDescriptorCollection を取得します。次に、インデックスを付けて PropertyDescriptorCollection から GetLanguage プロパティを検索します。そして、このプロパティの属性を返し、その属性を属性変数に保存します。

最後に、AttributeCollection から DesignOnlyAttribute を取得し、取得した情報をコンソール画面に書き込むことによって、プロパティを設定できるのがデザイン時だけかどうかを出力します。

' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("GetLanguage").Attributes

' Prints the description by retrieving the DescriptionAttribute
' from the AttributeCollection. 
Dim myAttribute As DesignOnlyAttribute = _
    CType(attributes(GetType(DesignOnlyAttribute)), DesignOnlyAttribute)
Console.WriteLine(("This property is design only :"
 & _
    myAttribute.IsDesignOnly.ToString()))
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["GetLanguage"].Attributes;
 
 /* Prints the description by retrieving the DescriptionAttribute 
  * 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.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this
 )[ "GetLanguage" ]->Attributes;

/* Prints the description by retrieving the DescriptionAttribute 
       * 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).
    get_Item("GetLanguage").get_Attributes();

/* Prints the description by retrieving the DescriptionAttribute 
   from the AttributeCollection. 
 */
DesignOnlyAttribute myAttribute = (DesignOnlyAttribute)(attributes.
    get_Item(DesignOnlyAttribute.class.ToType()));

Console.WriteLine("This property is design only :" 
    + System.Convert.ToString(myAttribute.get_IsDesignOnly()));
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.DesignOnlyAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DesignOnlyAttribute コンストラクタ


DesignOnlyAttribute フィールド


DesignOnlyAttribute プロパティ


DesignOnlyAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の DesignOnlyAttribute と等しいかどうかを示す値を返します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。  
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 この属性が既定値かどうかを判断します。
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

DesignOnlyAttribute メンバ

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

DesignOnlyAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DesignOnlyAttribute DesignOnlyAttribute クラスの新しいインスタンスを初期化します。
パブリック フィールドパブリック フィールド
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ IsDesignOnly プロパティを設定できるのがデザイン時だけかどうかを示す値を取得します。
パブリック プロパティ TypeId  派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の DesignOnlyAttribute と等しいかどうかを示す値を返します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。  
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 この属性が既定値かどうかを判断します。
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「DesignOnlyAttribute」の関連用語

DesignOnlyAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DesignOnlyAttributeのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS