Breyta

Deila með


AmbientValueAttribute Constructors

Definition

Initializes a new instance of the AmbientValueAttribute class.

Overloads

AmbientValueAttribute(Boolean)

Initializes a new instance of the AmbientValueAttribute class, given a Boolean value for its value.

AmbientValueAttribute(Byte)

Initializes a new instance of the AmbientValueAttribute class, given an 8-bit unsigned integer for its value.

AmbientValueAttribute(Char)

Initializes a new instance of the AmbientValueAttribute class, given a Unicode character for its value.

AmbientValueAttribute(Double)

Initializes a new instance of the AmbientValueAttribute class, given a double-precision floating-point number for its value.

AmbientValueAttribute(Int16)

Initializes a new instance of the AmbientValueAttribute class, given a 16-bit signed integer for its value.

AmbientValueAttribute(Int32)

Initializes a new instance of the AmbientValueAttribute class, given a 32-bit signed integer for its value.

AmbientValueAttribute(Int64)

Initializes a new instance of the AmbientValueAttribute class, given a 64-bit signed integer for its value.

AmbientValueAttribute(Object)

Initializes a new instance of the AmbientValueAttribute class, given an object for its value.

AmbientValueAttribute(Single)

Initializes a new instance of the AmbientValueAttribute class, given a single-precision floating point number for its value.

AmbientValueAttribute(String)

Initializes a new instance of the AmbientValueAttribute class, given a string for its value.

AmbientValueAttribute(Type, String)

Initializes a new instance of the AmbientValueAttribute class, given the value and its type.

AmbientValueAttribute(Boolean)

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

Initializes a new instance of the AmbientValueAttribute class, given a Boolean value for its value.

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

Parameters

value
Boolean

The value of this attribute.

Applies to

AmbientValueAttribute(Byte)

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

Initializes a new instance of the AmbientValueAttribute class, given an 8-bit unsigned integer for its value.

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

Parameters

value
Byte

The value of this attribute.

Applies to

AmbientValueAttribute(Char)

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

Initializes a new instance of the AmbientValueAttribute class, given a Unicode character for its value.

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

Parameters

value
Char

The value of this attribute.

Applies to

AmbientValueAttribute(Double)

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

Initializes a new instance of the AmbientValueAttribute class, given a double-precision floating-point number for its value.

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

Parameters

value
Double

The value of this attribute.

Applies to

AmbientValueAttribute(Int16)

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

Initializes a new instance of the AmbientValueAttribute class, given a 16-bit signed integer for its value.

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

Parameters

value
Int16

The value of this attribute.

Applies to

AmbientValueAttribute(Int32)

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

Initializes a new instance of the AmbientValueAttribute class, given a 32-bit signed integer for its value.

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

Parameters

value
Int32

The value of this attribute.

Applies to

AmbientValueAttribute(Int64)

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

Initializes a new instance of the AmbientValueAttribute class, given a 64-bit signed integer for its value.

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

Parameters

value
Int64

The value of this attribute.

Applies to

AmbientValueAttribute(Object)

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

Initializes a new instance of the AmbientValueAttribute class, given an object for its value.

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)

Parameters

value
Object

The value of this attribute.

Applies to

AmbientValueAttribute(Single)

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

Initializes a new instance of the AmbientValueAttribute class, given a single-precision floating point number for its value.

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

Parameters

value
Single

The value of this attribute.

Applies to

AmbientValueAttribute(String)

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

Initializes a new instance of the AmbientValueAttribute class, given a string for its value.

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)

Parameters

value
String

The value of this attribute.

Applies to

AmbientValueAttribute(Type, String)

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

Initializes a new instance of the AmbientValueAttribute class, given the value and its type.

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)

Parameters

type
Type

The Type of the value parameter.

value
String

The value for this attribute.

Examples

The following code example demonstrates using AmbientValueAttribute to enforce ambient behavior for a property called AlertForeColor. For a full code listing, see How to: Apply Attributes in Windows Forms Controls.

[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

Applies to