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

DesignerAttribute クラス

コンポーネントに対するデザイン時サービスを実装するために使用するクラスを指定します。

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

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface,
 AllowMultiple:=True, Inherited:=True)> _
Public NotInheritable Class
 DesignerAttribute
    Inherits Attribute
Dim instance As DesignerAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true,
 Inherited=true)] 
public sealed class DesignerAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Interface, AllowMultiple=true,
 Inherited=true)] 
public ref class DesignerAttribute sealed :
 public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface,
 AllowMultiple=true, Inherited=true) */ 
public final class DesignerAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true,
 Inherited=true) 
public final class DesignerAttribute extends
 Attribute
解説解説
使用例使用例

MyForm というクラスを作成する方法を次の例に示します。MyForm には、このクラスが DocumentDesigner を使用することを指定する DesignerAttribute と、Form カテゴリを指定する DesignerCategoryAttribute という 2 つの属性があります。

<Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL",
 _
    GetType(IRootDesigner)), DesignerCategory("Form")>
 _
Public Class MyForm
    
    Inherits ContainerControl
    ' Insert code here.
End Class 'MyForm
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL"
,
 
    typeof(IRootDesigner)),
    DesignerCategory("Form")]
public class MyForm : ContainerControl {
    // Insert code here.
}
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL"
,
IRootDesigner::typeid),
DesignerCategory("Form")]
ref class MyForm: public ContainerControl{
   // Insert code here.
};
/** @attribute Designer("System.Windows.Forms.Design.DocumentDesigner,"+
    "System.Windows.Forms.Design.DLL", IRootDesigner.class)
    @attribute DesignerCategory("Form")
 */
public static class MyForm
 extends ContainerControl
{
    // Insert code here.
} //MyForm

MyForm のインスタンスを作成する例を次に示します。そのクラスの属性を取得し、DesignerAttribute を抽出してから、デザイナの名前を出力します。

Public Shared Function Main()
 As Integer
    ' Creates a new form.
    Dim myNewForm As New
 MyForm()
    
    ' Gets the attributes for the collection.
    Dim attributes As AttributeCollection =
 TypeDescriptor.GetAttributes(myNewForm)
    
    ' Prints the name of the designer by retrieving the DesignerAttribute
    ' from the AttributeCollection. 
    Dim myAttribute As DesignerAttribute =
 _
        CType(attributes(GetType(DesignerAttribute)), DesignerAttribute)
    Console.WriteLine(("The designer for this class is: "
 & myAttribute.DesignerTypeName))
    
    Return 0
End Function 'Main
public static int Main()
 {
    // Creates a new form.
    MyForm myNewForm = new MyForm();
 
    // Gets the attributes for the collection.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewForm);
 
    /* Prints the name of the designer by retrieving the DesignerAttribute
     * from the AttributeCollection. */
    DesignerAttribute myAttribute = 
       (DesignerAttribute)attributes[typeof(DesignerAttribute)];
    Console.WriteLine("The designer for this
 class is: " + myAttribute.DesignerTypeName);
  
    return 0;
}
int main()
{
   // Creates a new form.
   MyForm^ myNewForm = gcnew MyForm;

   // Gets the attributes for the collection.
   AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewForm );

   /* Prints the name of the designer by retrieving the DesignerAttribute
       * from the AttributeCollection. */
   DesignerAttribute^ myAttribute = dynamic_cast<DesignerAttribute^>(attributes[
 DesignerAttribute::typeid ]);
   Console::WriteLine( "The designer for this
 class is: {0}", myAttribute->DesignerTypeName );
   return 0;
}
public static void main(String[]
 args)
{
    // Creates a new form.
    MyForm myNewForm = new MyForm();

    // Gets the attributes for the collection.
    AttributeCollection attributes = 
        TypeDescriptor.GetAttributes(myNewForm);

    /* Prints the name of the designer by retrieving the 
       DesignerAttribute from the AttributeCollection. 
     */
    DesignerAttribute myAttribute = (DesignerAttribute)(
        attributes.get_Item(DesignerAttribute.class.ToType()));

    Console.WriteLine(("The designer for this
 class is: " 
        + myAttribute.get_DesignerTypeName()));
} //main
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.DesignerAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DesignerAttribute コンストラクタ (Type)

デザイン時サービスを提供する型を指定して、DesignerAttribute クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    designerType As Type _
)
Dim designerType As Type

Dim instance As New DesignerAttribute(designerType)
public DesignerAttribute (
    Type designerType
)
public:
DesignerAttribute (
    Type^ designerType
)
public DesignerAttribute (
    Type designerType
)
public function DesignerAttribute (
    designerType : Type
)

パラメータ

designerType

この属性がバインドされているコンポーネントに対してデザイン時サービスを提供するクラスを表す Type。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DesignerAttribute コンストラクタ (String, Type)

デザイナ クラスの名前とデザイナの基本クラスを指定して、DesignerAttribute クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    designerTypeName As String, _
    designerBaseType As Type _
)
Dim designerTypeName As String
Dim designerBaseType As Type

Dim instance As New DesignerAttribute(designerTypeName,
 designerBaseType)
public DesignerAttribute (
    string designerTypeName,
    Type designerBaseType
)
public:
DesignerAttribute (
    String^ designerTypeName, 
    Type^ designerBaseType
)
public DesignerAttribute (
    String designerTypeName, 
    Type designerBaseType
)
public function DesignerAttribute (
    designerTypeName : String, 
    designerBaseType : Type
)

パラメータ

designerTypeName

この属性がバインドされているコンポーネントに対してデザイン時サービスを提供する型の完全修飾名の連結、および、格納されているこの型のアセンブリの名前。

designerBaseType

designerTypeName と関連付ける基本クラスを表す Type。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DesignerAttribute コンストラクタ (String)

デザイン時サービスを提供する型の名前を指定して、DesignerAttribute クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    designerTypeName As String _
)
Dim designerTypeName As String

Dim instance As New DesignerAttribute(designerTypeName)
public DesignerAttribute (
    string designerTypeName
)
public:
DesignerAttribute (
    String^ designerTypeName
)
public DesignerAttribute (
    String designerTypeName
)
public function DesignerAttribute (
    designerTypeName : String
)

パラメータ

designerTypeName

この属性がバインドされているコンポーネントに対してデザイン時サービスを提供する型の完全修飾名の連結、および、格納されているこの型のアセンブリの名前。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DesignerAttribute コンストラクタ


DesignerAttribute コンストラクタ (Type, Type)

デザイナの型とデザイナ基本クラスを指定して、DesignerAttribute クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    designerType As Type, _
    designerBaseType As Type _
)
Dim designerType As Type
Dim designerBaseType As Type

Dim instance As New DesignerAttribute(designerType,
 designerBaseType)
public DesignerAttribute (
    Type designerType,
    Type designerBaseType
)
public:
DesignerAttribute (
    Type^ designerType, 
    Type^ designerBaseType
)
public DesignerAttribute (
    Type designerType, 
    Type designerBaseType
)
public function DesignerAttribute (
    designerType : Type, 
    designerBaseType : Type
)

パラメータ

designerType

この属性がバインドされているコンポーネントに対してデザイン時サービスを提供するクラスを表す Type。

designerBaseType

designerType と関連付ける基本クラスを表す Type。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DesignerAttribute コンストラクタ (String, String)

デザイナの型とデザイナの基本クラスを指定して、DesignerAttribute クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    designerTypeName As String, _
    designerBaseTypeName As String _
)
Dim designerTypeName As String
Dim designerBaseTypeName As String

Dim instance As New DesignerAttribute(designerTypeName,
 designerBaseTypeName)
public DesignerAttribute (
    string designerTypeName,
    string designerBaseTypeName
)
public:
DesignerAttribute (
    String^ designerTypeName, 
    String^ designerBaseTypeName
)
public DesignerAttribute (
    String designerTypeName, 
    String designerBaseTypeName
)
public function DesignerAttribute (
    designerTypeName : String, 
    designerBaseTypeName : String
)

パラメータ

designerTypeName

この属性がバインドされているコンポーネントに対してデザイン時サービスを提供する型の完全修飾名の連結、および、格納されているこの型のアセンブリの名前。

designerBaseTypeName

デザイナ クラスと関連付ける基本クラスの完全修飾名。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DesignerAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ DesignerBaseTypeName このデザイナの基本型の名前を取得します。
パブリック プロパティ DesignerTypeName このデザイナ属性と関連付けられているデザイナ型の名前を取得します。
パブリック プロパティ TypeId オーバーライドされます。 この属性型の一意の ID を取得します。
参照参照

関連項目

DesignerAttribute クラス
System.ComponentModel 名前空間
Attribute

DesignerAttribute メソッド


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

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

関連項目

DesignerAttribute クラス
System.ComponentModel 名前空間
Attribute

DesignerAttribute メンバ

コンポーネントに対するデザイン時サービスを実装するために使用するクラスを指定します。

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


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

関連項目

DesignerAttribute クラス
System.ComponentModel 名前空間
Attribute



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「DesignerAttribute」の関連用語

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

   

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



DesignerAttributeのページの著作権

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

©2026 GRAS Group, Inc.RSS