DesignerAttribute クラス

定義

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

public ref class DesignerAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)]
public sealed class DesignerAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)>]
type DesignerAttribute = class
    inherit Attribute
Public NotInheritable Class DesignerAttribute
Inherits Attribute
継承
DesignerAttribute
属性

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

[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL",
IRootDesigner::typeid),
DesignerCategory("Form")]
ref class MyForm: public ContainerControl{
   // Insert code here.
};
[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", _
    GetType(IRootDesigner)), DesignerCategory("Form")> _
Public Class MyForm
    
    Inherits ContainerControl
    ' Insert code here.
End Class

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

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

注釈

デザイン時サービスに使用するクラスは、 インターフェイスを実装する 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)

適用対象

こちらもご覧ください