CategoryAttribute クラス

定義

PropertyGrid コントロールが [項目別] モードに設定されているときに、コントロールに表示するプロパティまたはイベントを分類するカテゴリの名前を指定します。

public ref class CategoryAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public class CategoryAttribute : Attribute
public class CategoryAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type CategoryAttribute = class
    inherit Attribute
type CategoryAttribute = class
    inherit Attribute
Public Class CategoryAttribute
Inherits Attribute
継承
CategoryAttribute
属性

次の例では、プロパティを MyImage 作成します。 プロパティには、a と a DescriptionAttribute の 2 つの属性があります CategoryAttribute

   [Description("The image associated with the control"),Category("Appearance")]
   System::Drawing::Image^ get()
   {
      // Insert code here.
      return m_Image1;
   }

   void set( System::Drawing::Image^ )
   {
      // Insert code here.
   }
}
[Description("The image associated with the control"),Category("Appearance")] 
 public Image MyImage {
    get {
       // Insert code here.
       return image1;
    }
    set {
       // Insert code here.
    }
 }
<Description("The image associated with the control"), _
    Category("Appearance")> _
Public Property MyImage() As Image
    
    Get
        ' Insert code here.
        Return image1
    End Get
    Set
        ' Insert code here.
    End Set 
End Property

次の例では、.のカテゴリを取得します MyImage。 まず、コードはオブジェクトのすべてのプロパティを持つ a PropertyDescriptorCollection を取得します。 次に、取得するコードインデックスを PropertyDescriptorCollection 作成 MyImageします。 次に、このプロパティの属性を返し、変数 attributesに保存します。

次に、この例では、カテゴリをCategoryAttributeAttributeCollection取得し、コンソール画面に書き込んで印刷します。

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyImage" ]->Attributes;

// Prints the description by retrieving the CategoryAttribute.
// from the AttributeCollection.
CategoryAttribute^ myAttribute = static_cast<CategoryAttribute^>(attributes[ CategoryAttribute::typeid ]);
Console::WriteLine( myAttribute->Category );
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["MyImage"].Attributes;
 
 // Prints the description by retrieving the CategoryAttribute.
 // from the AttributeCollection.
 CategoryAttribute myAttribute = 
    (CategoryAttribute)attributes[typeof(CategoryAttribute)];
 Console.WriteLine(myAttribute.Category);
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("MyImage").Attributes

' Prints the description by retrieving the CategoryAttribute. 
' from the AttributeCollection.
Dim myAttribute As CategoryAttribute = _
    CType(attributes(GetType(CategoryAttribute)), CategoryAttribute)
    Console.WriteLine(myAttribute.Category)

注釈

A CategoryAttribute は、モードに設定されたコントロール内のプロパティまたはイベントを一覧表示するときに、関連付けられているプロパティまたはイベントを関連付けるカテゴリをPropertyGridCategorized示します。 CategoryAttributeプロパティまたはイベントに適用されていない場合は、PropertyGridそのプロパティが Misc カテゴリに関連付けられます。 任意の名前に対して新しいカテゴリを作成するには、コンストラクターのカテゴリの名前を CategoryAttribute指定します。

このプロパティは Category 、属性が表すカテゴリの名前を示します。 また、このプロパティは Category 、カテゴリ名の透過的なローカライズも提供します。

注意 (継承者)

定義済みの名前以外のカテゴリ名を使用し、カテゴリ名をローカライズする場合は、メソッドをオーバーライドする GetLocalizedString(String) 必要があります。

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

カテゴリ 説明
Action 使用可能なアクションに関連するプロパティ。
Appearance エンティティの表示方法に関連するプロパティ。
Behavior エンティティの動作に関連するプロパティ。
Data データとデータ ソースの管理に関連するプロパティ。
Default 既定のカテゴリにグループ化されたプロパティ。
Design デザイン時にのみ使用できるプロパティ。
DragDrop ドラッグ アンド ドロップ操作に関連するプロパティ。
Focus フォーカスに関連するプロパティ。
Format 書式設定に関連するプロパティ。
Key キーボードに関連するプロパティ。
Layout レイアウトに関連するプロパティ。
Mouse マウスに関連するプロパティ。
WindowStyle 最上位フォームのウィンドウ スタイルに関連するプロパティ。

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

コンストラクター

CategoryAttribute()

Default というカテゴリ名を使用して、CategoryAttribute クラスの新しいインスタンスを初期化します。

CategoryAttribute(String)

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

プロパティ

Action

Action カテゴリを表す CategoryAttribute を取得します。

Appearance

Appearance カテゴリを表す CategoryAttribute を取得します。

Asynchronous

Asynchronous カテゴリを表す CategoryAttribute を取得します。

Behavior

Behavior カテゴリを表す CategoryAttribute を取得します。

Category

この属性が適用されているプロパティまたはイベントのカテゴリ名を取得します。

Data

Data カテゴリを表す CategoryAttribute を取得します。

Default

Default カテゴリを表す CategoryAttribute を取得します。

Design

Design カテゴリを表す CategoryAttribute を取得します。

DragDrop

DragDrop カテゴリを表す CategoryAttribute を取得します。

Focus

Focus カテゴリを表す CategoryAttribute を取得します。

Format

Format カテゴリを表す CategoryAttribute を取得します。

Key

Key カテゴリを表す CategoryAttribute を取得します。

Layout

Layout カテゴリを表す CategoryAttribute を取得します。

Mouse

Mouse カテゴリを表す CategoryAttribute を取得します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)
WindowStyle

WindowStyle カテゴリを表す CategoryAttribute を取得します。

メソッド

Equals(Object)

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

GetHashCode()

この属性のハッシュ コードを返します。

GetLocalizedString(String)

指定したカテゴリのローカライズされた名前を検索します。

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)

適用対象

こちらもご覧ください