AmbientValueAttribute クラス
アセンブリ: System (system.dll 内)
構文<AttributeUsageAttribute(AttributeTargets.All)> _ Public NotInheritable Class AmbientValueAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.All)] public sealed class AmbientValueAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] public ref class AmbientValueAttribute sealed : public Attribute
解説コントロールのプロパティにアンビエント動作が適用される場合は、必ずこの属性が使用されます。アンビエント プロパティには Control.Font や Control.BackColor などがありますが、これらのプロパティは親プロパティに自身の値を照会します。
通常、ビジュアル デザイナは AmbientValueAttribute 属性を使用して、プロパティに永続的に適用する値を決定します。この値は、通常、プロパティに別のソースから値を取得させる働きをする値です。たとえば、Color.Empty は BackColor プロパティのアンビエント値として機能します。フォーム上にコントロールがあり、そのコントロールの BackColor プロパティがフォームの BackColor プロパティとは異なる色に設定されている場合、コントロールの BackColor を Color.Empty に設定することで、そのコントロールの BackColor プロパティをフォームと同じ値にリセットできます。
使用例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.Attribute
System.ComponentModel.AmbientValueAttribute
スレッド セーフ
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (Object)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照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 コンストラクタ (Int64)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (Type, String)
アセンブリ: System (system.dll 内)
構文
使用例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); }
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (Byte)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (Boolean)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (Single)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (Int16)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (Int32)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (Char)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (Double)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute コンストラクタ (String)
アセンブリ: System (system.dll 内)
構文
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照AmbientValueAttribute プロパティ
パブリック プロパティ| 名前 | 説明 | |
|---|---|---|
| TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |
| Value | AmbientValueAttribute の値であるオブジェクトを取得します。 |
参照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 から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
参照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 から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
参照- AmbientValueAttributeのページへのリンク