値とその型を指定して、AmbientValueAttribute クラスの新しいインスタンスを初期化します。
名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文
'宣言
Public Sub New ( _
type As Type, _
value As String _
)
'使用
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);
}
プラットフォーム
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
参照
関連項目
AmbientValueAttribute クラス
AmbientValueAttribute メンバ
System.ComponentModel 名前空間