CategoryAttributeとは? わかりやすく解説

CategoryAttribute クラス

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

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.All)> _
Public Class CategoryAttribute
    Inherits Attribute
Dim instance As CategoryAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public class CategoryAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class CategoryAttribute : public
 Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public class CategoryAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public class CategoryAttribute extends
 Attribute
解説解説

CategoryAttribute は、PropertyGrid コントロールが Categorized モード設定されているときに、コントロール表示するプロパティまたはイベント関連付けるカテゴリ示しますCategoryAttribute適用しないプロパティまたはイベントは、PropertyGrid によって Misc カテゴリ関連付けられます。CategoryAttributeコンストラクタカテゴリ名を指定することにより、任意の名前でカテゴリ新規作成できます

Category プロパティは、属性対応するカテゴリの名前を示しますCategory プロパティは、カテゴリ名の透過ローカリゼーション提供します

継承時の注意 定義済みの名前以外のカテゴリ名を使用しカテゴリ名をローカライズする場合は、GetLocalizedString メソッドオーバーライドする必要がありますまた、ローカリゼーションに独自のロジック採用する場合は、Category プロパティオーバーライドできますCategoryAttribute クラスは、次の共通カテゴリ定義します

詳細については、属性概要属性使用したメタデータ拡張 の各トピック参照してください
使用例使用例

MyImage プロパティ作成する例を次に示します。このプロパティには、DescriptionAttribute と CategoryAttribute2 つ属性あります

[Description("The image associated with the control"),Category("Appearance")]
 
 public Image MyImage {
    get {
       // Insert code here.
       return image1;
    }
    set {
       // Insert code here.
    }
 }
/** @attribute Description("The image associated with the control")
  * @attribute Category("Appearance")
 */
/** @property 
 */
public Image get_MyImage()
{
    // Insert code here.
    return image1;
} //get_MyImage

/** @property 
 */
public void set_MyImage(Image value)
{
    // Insert code here.
} //set_MyImage

MyImageカテゴリ取得する例を次に示します最初にオブジェクトすべてのプロパティ保持する PropertyDescriptorCollection を取得します次にPropertyDescriptorCollectionインデックス付けてMyImage取得します。そして、このプロパティ属性返し、その属性変数 attributes保存します

最後に、AttributeCollection から CategoryAttribute取得し取得した情報コンソール画面書き込むことによって、カテゴリ出力します

' 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)
// 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.
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)
    .get_Item("MyImage").get_Attributes();

// Prints the description by retrieving the CategoryAttribute.
// from the AttributeCollection.
CategoryAttribute myAttribute = (CategoryAttribute)(
    attributes.get_Item(CategoryAttribute.class.ToType()));
Console.WriteLine(myAttribute.get_Category());
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.CategoryAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

CategoryAttribute コンストラクタ ()


CategoryAttribute コンストラクタ (String)

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

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

public CategoryAttribute (
    string category
)
public:
CategoryAttribute (
    String^ category
)
public CategoryAttribute (
    String category
)
public function CategoryAttribute (
    category : String
)

パラメータ

category

カテゴリの名前。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

CategoryAttribute コンストラクタ

CategoryAttribute クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
CategoryAttribute () Default というカテゴリ名を使用してCategoryAttribute クラス新しインスタンス初期化します。
CategoryAttribute (String) 指定したカテゴリ名を使用してCategoryAttribute クラス新しインスタンス初期化します。
参照参照

関連項目

CategoryAttribute クラス
CategoryAttribute メンバ
System.ComponentModel 名前空間

CategoryAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。 ( Attribute から継承されます。)
パブリック プロパティ WindowStyle WindowStyle カテゴリを表す CategoryAttribute取得します
参照参照

関連項目

CategoryAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
EventDescriptor

CategoryAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals オーバーロードされますオーバーライドされます指定したオブジェクトの値が現在の CategoryAttribute と等しかどうかを示す値を返します
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 この属性ハッシュ コード返します
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 この属性既定値かどうか判断します
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CategoryAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
EventDescriptor

CategoryAttribute メンバ

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

CategoryAttribute データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド CategoryAttribute オーバーロードされます。 CategoryAttribute クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。(Attribute から継承されます。)
パブリック プロパティ WindowStyle WindowStyle カテゴリを表す CategoryAttribute取得します
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Equals オーバーロードされますオーバーライドされます指定したオブジェクトの値が現在の CategoryAttribute等しかどうかを示す値を返します
パブリック メソッド GetCustomAttribute  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用され指定した型のカスタム属性取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされますアセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されカスタム属性配列取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 この属性ハッシュ コード返します
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute オーバーライドされます。 この属性既定値かどうか判断します
パブリック メソッド IsDefined  オーバーロードされます指定した型のカスタム属性が、アセンブリモジュール、型のメンバ、またはメソッド パラメータ適用されているかどうか判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンス等しかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CategoryAttribute クラス
System.ComponentModel 名前空間
Attribute
PropertyDescriptor
EventDescriptor



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「CategoryAttribute」の関連用語

CategoryAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CategoryAttributeのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS