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のページの著作権

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

©2026 GRAS Group, Inc.RSS