RecommendedAsConfigurableAttribute クラス
メモ : このクラスは、互換性のために残されています。 旧式でない代替が必要な場合は、SettingsBindableAttribute を使用してください。
プロパティをアプリケーションの設定値として使用できることを指定します。 名前空間: System.ComponentModelアセンブリ: System (system.dll 内)

<AttributeUsageAttribute(AttributeTargets.Property)> _ <ObsoleteAttribute("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")> _ Public Class RecommendedAsConfigurableAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Property)] [ObsoleteAttribute("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")] public class RecommendedAsConfigurableAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property)] [ObsoleteAttribute(L"Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")] public ref class RecommendedAsConfigurableAttribute : public Attribute

RecommendedAsConfigurableAttribute に true を設定してマークされたプロパティは、[プロパティ] ウィンドウ の ConfigurableProperties の行を展開するときに表示されます。推奨される設定値のないプロパティや、RecommendedAsConfigurableAttribute に false を設定してマークされたプロパティは表示されません。これらのプロパティは、アプリケーションの設定値として使用できません。既定値は false です。
RecommendedAsConfigurableAttribute のないプロパティを Visual Studio .NET の設定値に関連付けるには、[プロパティ] ウィンドウの [設定] の下にある [...] ボタンをクリックし、リストから該当するプロパティを選択します。
![]() |
---|
true の RecommendedAsConfigurableAttribute を使用してプロパティをマークすると、この属性の値は定数メンバ Yes に設定されます。RecommendedAsConfigurableAttribute に false を設定してマークされたプロパティの場合、値は No になります。したがって、コード内でこの属性の値を確認する場合は、属性を RecommendedAsConfigurableAttribute.Yes または RecommendedAsConfigurableAttribute.No として指定する必要があります。 |
詳細については、属性の概要、属性を使用したメタデータの拡張 の各トピックを参照してください。
.

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

System.Attribute
System.ComponentModel.RecommendedAsConfigurableAttribute


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


RecommendedAsConfigurableAttribute メンバ
System.ComponentModel 名前空間
Attribute
PropertyDescriptor クラス
AttributeCollection クラス
PropertyDescriptorCollection クラス
- RecommendedAsConfigurableAttribute クラスのページへのリンク