DesignerCategoryAttribute クラス

定義

クラスのデザイナーが特定のカテゴリに属することを指定します。

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

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

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

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

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 
       * DesignerCategoryAttribute from the AttributeCollection. */
   DesignerCategoryAttribute^ myAttribute = dynamic_cast<DesignerCategoryAttribute^>(attributes[ DesignerCategoryAttribute::typeid ]);
   Console::WriteLine( "The category of the designer for this class is: {0}", myAttribute->Category );
   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 
     * DesignerCategoryAttribute from the AttributeCollection. */
    DesignerCategoryAttribute myAttribute = 
       (DesignerCategoryAttribute)attributes[typeof(DesignerCategoryAttribute)];
    Console.WriteLine("The category of the designer for this class is: " + myAttribute.Category);
  
    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
    ' DesignerCategoryAttribute from the AttributeCollection. 
    Dim myAttribute As DesignerCategoryAttribute = _
        CType(attributes(GetType(DesignerCategoryAttribute)), DesignerCategoryAttribute)
    Console.WriteLine(("The category of the designer for this class is: " + myAttribute.Category))
    Return 0
End Function 'Main

注釈

ビジュアル デザイナーは、デザイナー カテゴリを使用して、実装されるデザイナーの種類を開発環境に通知できます。 クラスにデザイナー カテゴリが指定されていない場合、開発環境では、クラスの設計が許可される場合と許可されない場合があります。 カテゴリは任意の名前で作成できます。

この属性を使用してクラスをマークすると、クラスは定数メンバーに設定されます。 コードでこの属性の値をチェックする場合は、定数メンバーを指定する必要があります。 次の表の Description 列には、各値が設定されている定数メンバーの一覧が表示されます。

クラスは DesignerCategoryAttribute 、次の一般的なカテゴリを定義します。

カテゴリ 説明
コンポーネント コンポーネントで使用されるデザイナー。 属性は定数メンバー DesignerCategoryAttribute.Componentに設定されます。
フォーム フォームで使用されるデザイナー。 属性は定数メンバー DesignerCategoryAttribute.Formに設定されます。
Designer デザイナーで使用されるデザイナー。 属性は定数メンバー DesignerCategoryAttribute.Genericに設定されます。
空の文字列 ("") これが既定のカテゴリです。

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

コンストラクター

DesignerCategoryAttribute()

空の文字列 ("") を使用して、DesignerCategoryAttribute クラスの新しいインスタンスを初期化します。

DesignerCategoryAttribute(String)

指定したカテゴリ名を使用して、DesignerCategoryAttribute クラスの新しいインスタンスを初期化します。

フィールド

Component

このカテゴリでマークされたコンポーネントが、コンポーネント デザイナーを使用することを指定します。 このフィールドは読み取り専用です。

Default

このカテゴリでマークされたコンポーネントが、コンポーネント デザイナーを使用できないことを指定します。 static フィールドは読み取り専用です。

Form

このカテゴリでマークされたコンポーネントが、フォーム デザイナーを使用することを指定します。 static フィールドは読み取り専用です。

Generic

このカテゴリでマークされたコンポーネントが、汎用デザイナーを使用することを指定します。 static フィールドは読み取り専用です。

プロパティ

Category

カテゴリの名前を取得します。

TypeId

この属性の一意の識別子を取得します。

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)

適用対象

こちらもご覧ください