DesignerCategoryAttribute クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
クラスのデザイナーが特定のカテゴリに属することを指定します。
public ref class DesignerCategoryAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
public sealed class DesignerCategoryAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)>]
type DesignerCategoryAttribute = class
inherit Attribute
Public NotInheritable Class DesignerCategoryAttribute
Inherits Attribute
- 継承
- 属性
例
次の例では、 MyForm というクラスを作成します。
MyFormには 2 つの属性があります。このクラスを指定するDesignerAttributeは、DocumentDesignerを使用し、DesignerCategoryAttribute カテゴリを指定するFormです。
[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();
// 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に設定されます。 |
| Form | フォームで使用されるデザイナー。 属性は定数メンバー DesignerCategoryAttribute.Formに設定されます。 |
| デザイナー | デザイナーで使用されるデザイナー。 属性は定数メンバー DesignerCategoryAttribute.Genericに設定されます。 |
| 空の文字列 ("") | これが既定のカテゴリです。 |
詳細については、「属性」を参照してください。
コンストラクター
| 名前 | 説明 |
|---|---|
| DesignerCategoryAttribute() |
空の文字列 ("") を使用して、 DesignerCategoryAttribute クラスの新しいインスタンスを初期化します。 |
| DesignerCategoryAttribute(String) |
指定したカテゴリ名を使用して、 DesignerCategoryAttribute クラスの新しいインスタンスを初期化します。 |
フィールド
| 名前 | 説明 |
|---|---|
| Component |
このカテゴリでマークされたコンポーネントがコンポーネント デザイナーを使用することを指定します。 このフィールドは読み取り専用です。 |
| Default |
このカテゴリでマークされたコンポーネントがビジュアル デザイナーを使用できないことを指定します。 この |
| Form |
このカテゴリでマークされたコンポーネントがフォーム デザイナーを使用することを指定します。 この |
| Generic |
このカテゴリでマークされたコンポーネントがジェネリック デザイナーを使用することを指定します。 この |
プロパティ
| 名前 | 説明 |
|---|---|
| Category |
カテゴリの名前を取得します。 |
| TypeId |
この属性の一意識別子を取得します。 |
メソッド
| 名前 | 説明 |
|---|---|
| Equals(Object) |
指定したオブジェクトの値が現在の DesignOnlyAttributeと等しいかどうかを返します。 |
| GetHashCode() |
このインスタンスのハッシュ コードを返します。 |
| GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
| IsDefaultAttribute() |
この属性が既定であるかどうかを判断します。 |
| 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) |