AmbientValueAttribute 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 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(Boolean)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
为类的值 AmbientValueAttribute 指定布尔值,初始化类的新实例。
public:
AmbientValueAttribute(bool value);
public AmbientValueAttribute(bool value);
new System.ComponentModel.AmbientValueAttribute : bool -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Boolean)
参数
- value
- Boolean
此属性的值。
适用于
AmbientValueAttribute(Byte)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
为类的值指定一个 8 位无符号整数,初始化该类的新实例 AmbientValueAttribute 。
public:
AmbientValueAttribute(System::Byte value);
public AmbientValueAttribute(byte value);
new System.ComponentModel.AmbientValueAttribute : byte -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Byte)
参数
- value
- Byte
此属性的值。
适用于
AmbientValueAttribute(Char)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
为类的值指定 Unicode 字符,初始化类的新实例 AmbientValueAttribute 。
public:
AmbientValueAttribute(char value);
public AmbientValueAttribute(char value);
new System.ComponentModel.AmbientValueAttribute : char -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Char)
参数
- value
- Char
此属性的值。
适用于
AmbientValueAttribute(Double)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
初始化类的新实例 AmbientValueAttribute ,给定其值的双精度浮点数。
public:
AmbientValueAttribute(double value);
public AmbientValueAttribute(double value);
new System.ComponentModel.AmbientValueAttribute : double -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Double)
参数
- value
- Double
此属性的值。
适用于
AmbientValueAttribute(Int16)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
为类的值指定一个 16 位带符号整数,初始化该类的新实例 AmbientValueAttribute 。
public:
AmbientValueAttribute(short value);
public AmbientValueAttribute(short value);
new System.ComponentModel.AmbientValueAttribute : int16 -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Short)
参数
- value
- Int16
此属性的值。
适用于
AmbientValueAttribute(Int32)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
为类的值指定 32 位有符号整数,初始化该类的新实例 AmbientValueAttribute 。
public:
AmbientValueAttribute(int value);
public AmbientValueAttribute(int value);
new System.ComponentModel.AmbientValueAttribute : int -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Integer)
参数
- value
- Int32
此属性的值。
适用于
AmbientValueAttribute(Int64)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
为类的值指定一个 64 位带符号整数,初始化该类的新实例 AmbientValueAttribute 。
public:
AmbientValueAttribute(long value);
public AmbientValueAttribute(long value);
new System.ComponentModel.AmbientValueAttribute : int64 -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Long)
参数
- value
- Int64
此属性的值。
适用于
AmbientValueAttribute(Object)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
为类的值指定对象,初始化类的新实例 AmbientValueAttribute 。
public:
AmbientValueAttribute(System::Object ^ value);
public AmbientValueAttribute(object? value);
public AmbientValueAttribute(object value);
new System.ComponentModel.AmbientValueAttribute : obj -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Object)
参数
- value
- Object
此属性的值。
适用于
AmbientValueAttribute(Single)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
为类的值指定单精度浮点数,初始化类的新实例 AmbientValueAttribute 。
public:
AmbientValueAttribute(float value);
public AmbientValueAttribute(float value);
new System.ComponentModel.AmbientValueAttribute : single -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Single)
参数
- value
- Single
此属性的值。
适用于
AmbientValueAttribute(String)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
为类的值 AmbientValueAttribute 指定字符串,初始化类的新实例。
public:
AmbientValueAttribute(System::String ^ value);
public AmbientValueAttribute(string? value);
public AmbientValueAttribute(string value);
new System.ComponentModel.AmbientValueAttribute : string -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As String)
参数
- value
- String
此属性的值。
适用于
AmbientValueAttribute(Type, String)
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
- Source:
- AmbientValueAttribute.cs
给定值及其类型,初始化类的新实例 AmbientValueAttribute 。
public:
AmbientValueAttribute(Type ^ type, System::String ^ value);
public AmbientValueAttribute(Type type, string value);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
public AmbientValueAttribute(Type type, string value);
new System.ComponentModel.AmbientValueAttribute : Type * string -> System.ComponentModel.AmbientValueAttribute
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")>]
new System.ComponentModel.AmbientValueAttribute : Type * string -> System.ComponentModel.AmbientValueAttribute
Public Sub New (type As Type, value As String)
参数
- value
- String
此属性的值。
- 属性
示例
下面的代码示例演示如何对 AmbientValueAttribute 调用 AlertForeColor的属性强制实施环境行为。 有关完整代码列表,请参阅如何:在Windows Forms控件中应用属性。
[AmbientValue(typeof(Color), "Empty")]
[Category("Appearance")]
[DefaultValue(typeof(Color), "White")]
[Description("The color used for painting alert text.")]
public Color AlertForeColor
{
get =>
_alertForeColorValue == Color.Empty &&
Parent != null
? Parent.ForeColor
: _alertForeColorValue;
set => _alertForeColorValue = value;
}
// This method is used by designers to enable resetting the
// property to its default value.
public void ResetAlertForeColor() =>
AlertForeColor = s_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.
bool ShouldSerializeAlertForeColor() =>
_alertForeColorValue != s_ambientColorValue;
<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 (Me.Parent IsNot 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