英語で読む

次の方法で共有


DesignerAttribute クラス

定義

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

C#
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)]
public sealed class DesignerAttribute : Attribute
継承
DesignerAttribute
属性

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

C#
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL", 
    typeof(IRootDesigner)),
    DesignerCategory("Form")]
public class MyForm : ContainerControl {
    // Insert code here.
}

次の例では、 の MyFormインスタンスを作成します。 次に、 クラスの属性を取得し、 を DesignerAttribute抽出し、デザイナーの名前を出力します。

C#
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;
}

注釈

デザイン時サービスに使用するクラスは、 インターフェイスを実装する IDesigner 必要があります。

デザイナーの DesignerBaseTypeName 基本型を検索するには、 プロパティを使用します。 プロパティを DesignerTypeName 使用して、このメンバーに関連付けられているデザイナーの種類の名前を取得します。

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

コンストラクター

DesignerAttribute(String)

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

DesignerAttribute(String, String)

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

DesignerAttribute(String, Type)

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

DesignerAttribute(Type)

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

DesignerAttribute(Type, Type)

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

プロパティ

DesignerBaseTypeName

このデザイナーの基本型の名前を取得します。

DesignerTypeName

このデザイナー属性と関連付けられているデザイナー型の名前を取得します。

TypeId

この属性型の一意の ID を取得します。

メソッド

Equals(Object)

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

GetHashCode()

このインスタンスのハッシュ コードを返します。

GetType()

現在のインスタンスの Type を取得します。

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

適用対象

製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

こちらもご覧ください