RecommendedAsConfigurableAttribute クラス

定義

注意事項

Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.

注意事項

RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.

プロパティをアプリケーションの設定値として使用できることを指定します。

public ref class RecommendedAsConfigurableAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
[System.Obsolete("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")]
public class RecommendedAsConfigurableAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
public class RecommendedAsConfigurableAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
[System.Obsolete("RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.")]
public class RecommendedAsConfigurableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
[<System.Obsolete("Use System.ComponentModel.SettingsBindableAttribute instead to work with the new settings model.")>]
type RecommendedAsConfigurableAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
type RecommendedAsConfigurableAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
[<System.Obsolete("RecommendedAsConfigurableAttribute has been deprecated. Use System.ComponentModel.SettingsBindableAttribute instead.")>]
type RecommendedAsConfigurableAttribute = class
    inherit Attribute
Public Class RecommendedAsConfigurableAttribute
Inherits Attribute
継承
RecommendedAsConfigurableAttribute
属性

次の例では、プロパティをアプリケーション設定として使用可能としてマークします。

public:
   [RecommendedAsConfigurable(true)]
   property int MyProperty 
   {
      int get()
      {
         // Insert code here.
         return 0;
      }
      void set( int /*value*/ )
      {
         // Insert code here.
      }
   }
[RecommendedAsConfigurable(true)]
 public int MyProperty {
    get {
       // Insert code here.
       return 0;
    }
    set {
       // Insert code here.
    }
 }
<RecommendedAsConfigurable(True)> _
Public Property MyProperty() As Integer
    Get
        ' Insert code here.
        Return 0
    End Get
    Set
        ' Insert code here.
    End Set 
End Property

次の例では、 の 値をチェックする方法をRecommendedAsConfigurableAttributeMyProperty示します。 最初に、コードは オブジェクトのすべてのプロパティを持つ を取得 PropertyDescriptorCollection します。 次に、 に PropertyDescriptorCollection インデックスを作成して を取得 MyPropertyします。 次に、このプロパティの属性を返し、それらを attributes 変数に保存します。

この例では、 の値を確認する 2 つの異なる方法を示します RecommendedAsConfigurableAttribute。 2 番目のコード フラグメントでは、 メソッドを呼び出します Equals 。 最後のコード フラグメントでは、 プロパティをRecommendedAsConfigurable使用して値をチェックします。

// 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)["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.
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

でクラスをマークした場合はRecommendedAsConfigurableAttribute、次のコードを使用して値をチェックします。

AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty );
if ( attributes[ RecommendedAsConfigurableAttribute::typeid ]->Equals( RecommendedAsConfigurableAttribute::Yes ) )
{
   // Insert code here.
}
AttributeCollection attributes = 
   TypeDescriptor.GetAttributes(MyProperty);
if(attributes[typeof(RecommendedAsConfigurableAttribute)].Equals(RecommendedAsConfigurableAttribute.Yes)) {
   // Insert code here.
}
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
If attributes(GetType(RecommendedAsConfigurableAttribute)).Equals(RecommendedAsConfigurableAttribute.Yes) Then
    ' Insert code here.
End If

注釈

[プロパティ] ウィンドウで RecommendedAsConfigurableAttribute[構成可能なプロパティ] 行を展開したときに表示するtrueセットでマークされているプロパティ。 推奨設定がないプロパティ、または に設定falseされているプロパティはRecommendedAsConfigurableAttribute表示されず、アプリケーション設定の候補とは考えにくいです。 既定値は、false です。

を持RecommendedAsConfigurableAttributeたないプロパティを Visual Studio の設定にバインドするには、[プロパティ] ウィンドウの [設定] の下にある省略記号ボタン (...) をクリックし、一覧から適切なプロパティを選択します。

注意

を にtrue設定して プロパティRecommendedAsConfigurableAttributeをマークすると、この属性の値は定数メンバー Yesに設定されます。 が value falseに設定されたRecommendedAsConfigurableAttributeプロパティの場合、値は ですNo。 したがって、コードでこの属性の値をチェックする場合は、 属性を または RecommendedAsConfigurableAttribute.NoとしてRecommendedAsConfigurableAttribute.Yes指定する必要があります。

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

.

コンストラクター

RecommendedAsConfigurableAttribute(Boolean)
古い.
古い.

RecommendedAsConfigurableAttribute クラスの新しいインスタンスを初期化します。

フィールド

Default
古い.
古い.

RecommendedAsConfigurableAttribute の既定値 (No) を指定します。 static フィールドは読み取り専用です。

No
古い.
古い.

プロパティをアプリケーションの設定値として使用できないことを指定します。 static フィールドは読み取り専用です。

Yes
古い.
古い.

プロパティをアプリケーションの設定値として使用できることを指定します。 static フィールドは読み取り専用です。

プロパティ

RecommendedAsConfigurable
古い.
古い.

この属性が関連付けられているプロパティをアプリケーション設定値として使用できるかどうかを示す値を取得します。

TypeId
古い.
古い.

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

(継承元 Attribute)

メソッド

Equals(Object)
古い.
古い.

このインスタンスと指定したオブジェクトが等しいかどうかを示します。

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)

適用対象

こちらもご覧ください