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.

C#
public AmbientValueAttribute(bool value);

Parameters

value
Boolean

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(byte value);

Parameters

value
Byte

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(char value);

Parameters

value
Char

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(double value);

Parameters

value
Double

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(short value);

Parameters

value
Int16

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(int value);

Parameters

value
Int32

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(long value);

Parameters

value
Int64

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(object? value);
C#
public AmbientValueAttribute(object value);

Parameters

value
Object

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(float value);

Parameters

value
Single

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(string? value);
C#
public AmbientValueAttribute(string value);

Parameters

value
String

The value of this attribute.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public AmbientValueAttribute(Type type, string value);

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.

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

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1