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

AmbientValueAttribute クラス

プロパティ別のソースから値を取得させる目的で、そのプロパティに渡す値を指定しますこのような動作アンビエンス呼ばれます。このクラス継承できません。

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

<AttributeUsageAttribute(AttributeTargets.All)> _
Public NotInheritable Class
 AmbientValueAttribute
    Inherits Attribute
Dim instance As AmbientValueAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public sealed class AmbientValueAttribute :
 Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class AmbientValueAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public final class AmbientValueAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public final class AmbientValueAttribute extends
 Attribute
解説解説
使用例使用例

AmbientValueAttribute使用してAlertForeColor というプロパティアンビエント動作適用するコード例次に示します。完全なコードの一覧については、「方法 : Windows フォーム コントロール属性適用する」を参照してください

<AmbientValue(GetType(Color), "Empty"),
 _
Category("Appearance"), _
DefaultValue(GetType(Color), "White"),
 _
Description("The color used for painting alert text.")>
 _
Public Property AlertForeColor() As
 Color
    Get
        If Me.alertForeColorValue = Color.Empty
 AndAlso Not (Me.Parent
 Is Nothing) Then
            Return Parent.ForeColor
        End If

        Return Me.alertForeColorValue
    End Get

    Set(ByVal value As Color)
        Me.alertForeColorValue = value
    End Set
End Property

' This method is used by designers to enable resetting the
' property to its default value.
Public Sub ResetAlertForeColor()
    Me.AlertForeColor = AttributesDemoControl.defaultAlertForeColorValue
End Sub

' This method indicates to designers whether the property
' value is different from the ambient value, in which case
' the designer should persist the value.
Private Function ShouldSerializeAlertForeColor()
 As Boolean
    Return Me.alertForeColorValue <>
 AttributesDemoControl.ambientColorValue
End Function
[AmbientValue(typeof(Color), "Empty")]
[Category("Appearance")]
[DefaultValue(typeof(Color), "White")]
[Description("The color used for painting alert text.")]
public Color AlertForeColor
{
    get
    {
        if (this.alertForeColorValue == Color.Empty
 &&
            this.Parent != null)
        {
            return Parent.ForeColor;
        }

        return this.alertForeColorValue;
    }

    set
    {
        this.alertForeColorValue = value;
    }
}

// This method is used by designers to enable resetting the
// property to its default value.
public void ResetAlertForeColor()
{
    this.AlertForeColor = AttributesDemoControl.defaultAlertForeColorValue;
}

// This method indicates to designers whether the property
// value is different from the ambient value, in which case
// the designer should persist the value.
private bool ShouldSerializeAlertForeColor()
{
    return (this.alertForeColorValue != AttributesDemoControl.ambientColorValue);
}
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.AmbientValueAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

AmbientValueAttribute コンストラクタ (Object)


AmbientValueAttribute コンストラクタ

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

名前 説明
AmbientValueAttribute (Boolean) 値としてブール値を指定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (Byte) 値として 8 ビット符号なし整数指定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (Char) 値として Unicode 文字指定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (Double) 値として倍精度浮動小数点数指定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (Int16) 値として 16 ビット符号付き整数指定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (Int32) 値として 32 ビット符号付き整数指定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (Int64) 値として 64 ビット符号付き整数指定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (Object) 値としてオブジェクト指定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (Single) 値として単精度浮動小数点数指定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (String) 値として文字列設定してAmbientValueAttribute クラス新しインスタンス初期化します。
AmbientValueAttribute (Type, String) 値とその型を指定してAmbientValueAttribute クラス新しインスタンス初期化します。
参照参照

関連項目

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

AmbientValueAttribute コンストラクタ (Int64)


AmbientValueAttribute コンストラクタ (Type, String)

値とその型を指定して、AmbientValueAttribute クラス新しインスタンス初期化します。

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

Dim type As Type
Dim value As String

Dim instance As New AmbientValueAttribute(type,
 value)
public AmbientValueAttribute (
    Type type,
    string value
)
public:
AmbientValueAttribute (
    Type^ type, 
    String^ value
)
public AmbientValueAttribute (
    Type type, 
    String value
)
public function AmbientValueAttribute (
    type : Type, 
    value : String
)

パラメータ

type

value パラメータType

value

この属性の値。

使用例使用例

AmbientValueAttribute使用してAlertForeColor というプロパティアンビエント動作適用するコード例次に示します。完全なコードの一覧については、「方法 : Windows フォーム コントロール属性適用する」を参照してください

<AmbientValue(GetType(Color), "Empty"),
 _
Category("Appearance"), _
DefaultValue(GetType(Color), "White"),
 _
Description("The color used for painting alert text.")>
 _
Public Property AlertForeColor() As
 Color
    Get
        If Me.alertForeColorValue = Color.Empty
 AndAlso Not (Me.Parent
 Is Nothing) Then
            Return Parent.ForeColor
        End If

        Return Me.alertForeColorValue
    End Get

    Set(ByVal value As Color)
        Me.alertForeColorValue = value
    End Set
End Property

' This method is used by designers to enable resetting the
' property to its default value.
Public Sub ResetAlertForeColor()
    Me.AlertForeColor = AttributesDemoControl.defaultAlertForeColorValue
End Sub

' This method indicates to designers whether the property
' value is different from the ambient value, in which case
' the designer should persist the value.
Private Function ShouldSerializeAlertForeColor()
 As Boolean
    Return Me.alertForeColorValue <>
 AttributesDemoControl.ambientColorValue
End Function
[AmbientValue(typeof(Color), "Empty")]
[Category("Appearance")]
[DefaultValue(typeof(Color), "White")]
[Description("The color used for painting alert text.")]
public Color AlertForeColor
{
    get
    {
        if (this.alertForeColorValue == Color.Empty
 &&
            this.Parent != null)
        {
            return Parent.ForeColor;
        }

        return this.alertForeColorValue;
    }

    set
    {
        this.alertForeColorValue = value;
    }
}

// This method is used by designers to enable resetting the
// property to its default value.
public void ResetAlertForeColor()
{
    this.AlertForeColor = AttributesDemoControl.defaultAlertForeColorValue;
}

// This method indicates to designers whether the property
// value is different from the ambient value, in which case
// the designer should persist the value.
private bool ShouldSerializeAlertForeColor()
{
    return (this.alertForeColorValue != AttributesDemoControl.ambientColorValue);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AmbientValueAttribute クラス
AmbientValueAttribute メンバ
System.ComponentModel 名前空間

AmbientValueAttribute コンストラクタ (Byte)


AmbientValueAttribute コンストラクタ (Boolean)


AmbientValueAttribute コンストラクタ (Single)


AmbientValueAttribute コンストラクタ (Int16)


AmbientValueAttribute コンストラクタ (Int32)


AmbientValueAttribute コンストラクタ (Char)


AmbientValueAttribute コンストラクタ (Double)


AmbientValueAttribute コンストラクタ (String)


AmbientValueAttribute プロパティ


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

  名前 説明
パブリック プロパティ TypeId  派生クラス実装されている場合は、この Attribute一意識別子取得します。 ( Attribute から継承されます。)
パブリック プロパティ Value AmbientValueAttribute の値であるオブジェクト取得します
参照参照

関連項目

AmbientValueAttribute クラス
System.ComponentModel 名前空間

AmbientValueAttribute メソッド


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

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

関連項目

AmbientValueAttribute クラス
System.ComponentModel 名前空間

AmbientValueAttribute メンバ

プロパティ別のソースから値を取得させる目的で、そのプロパティに渡す値を指定しますこのような動作アンビエンス呼ばれます。このクラス継承できません。

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


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

関連項目

AmbientValueAttribute クラス
System.ComponentModel 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「AmbientValueAttribute」の関連用語

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

   

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



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

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

©2026 GRAS Group, Inc.RSS