AmbientValueAttribute Costruttori

Definizione

Inizializza una nuova istanza della classe AmbientValueAttribute.

Overload

AmbientValueAttribute(Boolean)

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un valore Boolean come relativo valore.

AmbientValueAttribute(Byte)

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un intero senza segno a 8 bit come relativo valore.

AmbientValueAttribute(Char)

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un carattere Unicode come relativo valore.

AmbientValueAttribute(Double)

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un numero in virgola mobile e precisione doppia come relativo valore.

AmbientValueAttribute(Int16)

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un intero con segno a 16 bit come relativo valore.

AmbientValueAttribute(Int32)

Inizializza una nuova istanza della classe AmbientValueAttribute, dato un intero con segno a 32 bit come relativo valore.

AmbientValueAttribute(Int64)

Inizializza una nuova istanza della classe AmbientValueAttribute, dato un intero con segno a 64 bit come relativo valore.

AmbientValueAttribute(Object)

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un oggetto come relativo valore.

AmbientValueAttribute(Single)

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un numero in virgola mobile e precisione singola come relativo valore.

AmbientValueAttribute(String)

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, data una stringa come relativo valore.

AmbientValueAttribute(Type, String)

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato il valore e il relativo tipo.

AmbientValueAttribute(Boolean)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un valore Boolean come relativo valore.

public:
 AmbientValueAttribute(bool value);
public AmbientValueAttribute (bool value);
new System.ComponentModel.AmbientValueAttribute : bool -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Boolean)

Parametri

value
Boolean

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(Byte)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un intero senza segno a 8 bit come relativo valore.

public:
 AmbientValueAttribute(System::Byte value);
public AmbientValueAttribute (byte value);
new System.ComponentModel.AmbientValueAttribute : byte -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Byte)

Parametri

value
Byte

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(Char)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un carattere Unicode come relativo valore.

public:
 AmbientValueAttribute(char value);
public AmbientValueAttribute (char value);
new System.ComponentModel.AmbientValueAttribute : char -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Char)

Parametri

value
Char

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(Double)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un numero in virgola mobile e precisione doppia come relativo valore.

public:
 AmbientValueAttribute(double value);
public AmbientValueAttribute (double value);
new System.ComponentModel.AmbientValueAttribute : double -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Double)

Parametri

value
Double

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(Int16)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un intero con segno a 16 bit come relativo valore.

public:
 AmbientValueAttribute(short value);
public AmbientValueAttribute (short value);
new System.ComponentModel.AmbientValueAttribute : int16 -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Short)

Parametri

value
Int16

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(Int32)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Inizializza una nuova istanza della classe AmbientValueAttribute, dato un intero con segno a 32 bit come relativo valore.

public:
 AmbientValueAttribute(int value);
public AmbientValueAttribute (int value);
new System.ComponentModel.AmbientValueAttribute : int -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Integer)

Parametri

value
Int32

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(Int64)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Inizializza una nuova istanza della classe AmbientValueAttribute, dato un intero con segno a 64 bit come relativo valore.

public:
 AmbientValueAttribute(long value);
public AmbientValueAttribute (long value);
new System.ComponentModel.AmbientValueAttribute : int64 -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Long)

Parametri

value
Int64

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(Object)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un oggetto come relativo valore.

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)

Parametri

value
Object

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(Single)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato un numero in virgola mobile e precisione singola come relativo valore.

public:
 AmbientValueAttribute(float value);
public AmbientValueAttribute (float value);
new System.ComponentModel.AmbientValueAttribute : single -> System.ComponentModel.AmbientValueAttribute
Public Sub New (value As Single)

Parametri

value
Single

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(String)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, data una stringa come relativo valore.

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)

Parametri

value
String

Il valore di questo attributo.

Si applica a

AmbientValueAttribute(Type, String)

Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs
Source:
AmbientValueAttribute.cs

Consente di inizializzare una nuova istanza della classe AmbientValueAttribute, dato il valore e il relativo tipo.

public:
 AmbientValueAttribute(Type ^ type, System::String ^ value);
public AmbientValueAttribute (Type type, string value);
new System.ComponentModel.AmbientValueAttribute : Type * string -> System.ComponentModel.AmbientValueAttribute
Public Sub New (type As Type, value As String)

Parametri

type
Type

Oggetto Type del parametro value.

value
String

Valore di questo attributo.

Esempio

Nell'esempio di codice seguente viene illustrato l'uso AmbientValueAttribute per applicare il comportamento dell'ambiente per una proprietà denominata AlertForeColor. Per un elenco di codice completo, vedere Procedura: Applicare attributi nei controlli Windows Forms.

[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);
}
<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

Si applica a