BrowsableAttribute クラス
アセンブリ: System (system.dll 内)

<AttributeUsageAttribute(AttributeTargets.All)> _ Public NotInheritable Class BrowsableAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets::All)] public ref class BrowsableAttribute sealed : public Attribute

通常、ビジュアルなデザイナは、参照できる属性を持たないメンバ、または値 true の BrowsableAttribute コンストラクタを使用してマークされているメンバを [プロパティ] ウィンドウに表示します。これらのメンバはデザイン時に変更できます。値 false の BrowsableAttribute コンストラクタを使用してマークされているメンバは、デザイン時に編集できないため、ビジュアルなデザイナには表示されません。既定値は true です。
![]() |
---|
値 true の BrowsableAttribute コンストラクタを使用してプロパティをマークすると、この属性の値は定数メンバ Yes に設定されます。値 false の BrowsableAttribute コンストラクタを使用してマークされているプロパティの場合、値は No になります。したがって、コード内でこの属性の値を確認する場合は、属性を BrowsableAttribute.Yes または BrowsableAttribute.No として指定する必要があります。 |

<Browsable(True)> _ Public Property MyProperty() As Integer Get ' Insert code here. Return 0 End Get Set ' Insert code here. End Set End Property
[Browsable(true)] public int MyProperty { get { // Insert code here. return 0; } set { // Insert code here. } }
public: [Browsable(true)] property int MyProperty { int get() { // Insert code here. return 0; } void set( int value ) { // Insert code here. } }
/** @attribute Browsable(true) */ /** @property */ public int get_MyProperty() { // Insert code here. return 0; } //get_MyProperty /** @property */ public void set_MyProperty(int value) { // Insert code here. } //set_MyProperty
Browsable(true) public function get MyProperty() : int { // Insert code here. return 0; } public function set MyProperty(value : int) { }
MyProperty の BrowsableAttribute の値を確認する方法を次の例に示します。最初に、オブジェクトのすべてのプロパティを保持する PropertyDescriptorCollection を取得します。次に、PropertyDescriptorCollection にインデックスを付けて、MyProperty を取得します。そして、このプロパティの属性を返し、その属性を属性変数に保存します。
この例では、BrowsableAttribute の値を確認する 2 種類の方法を示します。2 番目のコード片では、Equals メソッドを呼び出します。最後のコード片では、Browsable プロパティを使用して値を確認します。
' Gets the attributes for the property. Dim attributes As AttributeCollection = _ TypeDescriptor.GetProperties(Me)("MyProperty").Attributes ' Checks to see if the value of the BrowsableAttribute is Yes. If attributes(GetType(BrowsableAttribute)).Equals(BrowsableAttribute.Yes) Then ' Insert code here. End If ' This is another way to see whether the property is browsable. Dim myAttribute As BrowsableAttribute = _ CType(attributes(GetType(BrowsableAttribute)), BrowsableAttribute) If myAttribute.Browsable Then ' Insert code here. End If
// Gets the attributes for the property. AttributeCollection attributes = TypeDescriptor.GetProperties(this)["MyProperty"].Attributes; // Checks to see if the value of the BrowsableAttribute is Yes. if(attributes[typeof(BrowsableAttribute)].Equals(BrowsableAttribute.Yes)) { // Insert code here. } // This is another way to see whether the property is browsable. BrowsableAttribute myAttribute = (BrowsableAttribute)attributes[typeof(BrowsableAttribute)]; if(myAttribute.Browsable) { // Insert code here. }
// Gets the attributes for the property. AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes; // Checks to see if the value of the BrowsableAttribute is Yes. if ( attributes[ BrowsableAttribute::typeid ]->Equals( BrowsableAttribute::Yes ) ) { // Insert code here. } // This is another way to see whether the property is browsable. BrowsableAttribute^ myAttribute = dynamic_cast<BrowsableAttribute^>(attributes[ BrowsableAttribute::typeid ]); if ( myAttribute->Browsable ) { // Insert code here. }
// Gets the attributes for the property. AttributeCollection attributes = TypeDescriptor.GetProperties(this). get_Item("MyProperty").get_Attributes(); // Checks to see if the value of the BrowsableAttribute is Yes. if (attributes.get_Item(BrowsableAttribute.class.ToType()).Equals( BrowsableAttribute.Yes)) { // Insert code here. } // This is another way to see whether the property is browsable. BrowsableAttribute myAttribute = (BrowsableAttribute) (attributes.get_Item(BrowsableAttribute.class.ToType())); if (myAttribute.get_Browsable()) { // Insert code here. }
// Gets the attributes for the property. var attributes : AttributeCollection = TypeDescriptor.GetProperties(this)["MyProperty"].Attributes; // Checks to see if the value of the BrowsableAttribute is Yes. if(attributes[BrowsableAttribute].Equals(BrowsableAttribute.Yes)) { Console.WriteLine("MyProperty is browsable."); } // This is another way to see whether the property is browsable. var myAttribute : BrowsableAttribute = BrowsableAttribute(attributes[BrowsableAttribute]); if(myAttribute.Browsable) { Console.WriteLine("MyProperty is browsable."); }
BrowsableAttribute を使用してクラスをマークした場合は、次のコードを使用して値を確認します。
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty) If attributes(GetType(BrowsableAttribute)).Equals(BrowsableAttribute.Yes) Then ' Insert code here. End If
AttributeCollection attributes = TypeDescriptor.GetAttributes(MyProperty); if(attributes[typeof(BrowsableAttribute)].Equals(BrowsableAttribute.Yes)) { // Insert code here. }
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty ); if ( attributes[ BrowsableAttribute::typeid ]->Equals( BrowsableAttribute::Yes ) ) { // Insert code here. }
AttributeCollection attributes = TypeDescriptor.GetAttributes((Int32)get_MyProperty()); if (attributes.get_Item(BrowsableAttribute.class.ToType()).Equals( BrowsableAttribute.Yes)) { // Insert code here. }
var attributes : AttributeCollection = TypeDescriptor.GetAttributes(MyProperty); if(attributes[BrowsableAttribute].Equals(BrowsableAttribute.Yes)) { Console.WriteLine("MyProperty is browsable."); }

System.Attribute
System.ComponentModel.BrowsableAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


BrowsableAttribute コンストラクタ
アセンブリ: System (system.dll 内)


値 true の BrowsableAttribute コンストラクタを使用してプロパティをマークすると、この属性の値は定数メンバ Yes に設定されます。値 false の BrowsableAttribute コンストラクタを使用してマークされているプロパティの場合、値は No になります。したがって、コード内でこの属性の値を確認する場合は、属性を BrowsableAttribute.Yes または BrowsableAttribute.No として指定する必要があります。

プロパティを参照可能としてマークする例を次に示します。このコードは、新しい BrowsableAttribute を作成し、その値を BrowsableAttribute.Yes に設定してから、その属性をプロパティに関連付けます。
<Browsable(True)> _ Public Property MyProperty() As Integer Get ' Insert code here. Return 0 End Get Set ' Insert code here. End Set End Property
[Browsable(true)] public int MyProperty { get { // Insert code here. return 0; } set { // Insert code here. } }
[Browsable(true)] int get() { // Insert code here. return 0; } void set( int value ) { // Insert code here. } }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


BrowsableAttribute フィールド

名前 | 説明 | |
---|---|---|
![]() | Default | BrowsableAttribute の既定値 (Yes) を指定します。static フィールドは読み取り専用です。 |
![]() | No | 特定のプロパティまたはイベントをデザイン時に変更できないことを指定します。static フィールドは読み取り専用です。 |
![]() | Yes | 特定のプロパティまたはイベントをデザイン時に変更できることを指定します。static フィールドは読み取り専用です。 |

関連項目
BrowsableAttribute クラスSystem.ComponentModel 名前空間
Attribute
PropertyDescriptor
EventDescriptor
AttributeCollection クラス
PropertyDescriptorCollection
BrowsableAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() | Browsable | オブジェクトが参照可能かどうかを示す値を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |

関連項目
BrowsableAttribute クラスSystem.ComponentModel 名前空間
Attribute
PropertyDescriptor
EventDescriptor
AttributeCollection クラス
PropertyDescriptorCollection
BrowsableAttribute メソッド

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

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

関連項目
BrowsableAttribute クラスSystem.ComponentModel 名前空間
Attribute
PropertyDescriptor
EventDescriptor
AttributeCollection クラス
PropertyDescriptorCollection
BrowsableAttribute メンバ
[プロパティ] ウィンドウにプロパティやイベントを表示するかどうかを指定します。
BrowsableAttribute データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Default | BrowsableAttribute の既定値 (Yes) を指定します。static フィールドは読み取り専用です。 |
![]() | No | 特定のプロパティまたはイベントをデザイン時に変更できないことを指定します。static フィールドは読み取り専用です。 |
![]() | Yes | 特定のプロパティまたはイベントをデザイン時に変更できることを指定します。static フィールドは読み取り専用です。 |

名前 | 説明 | |
---|---|---|
![]() | Browsable | オブジェクトが参照可能かどうかを示す値を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |

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

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

関連項目
BrowsableAttribute クラスSystem.ComponentModel 名前空間
Attribute
PropertyDescriptor
EventDescriptor
AttributeCollection クラス
PropertyDescriptorCollection
- BrowsableAttributeのページへのリンク