IRangeValueProvider.SetValue(Double) Methode

Definition

Legt den Wert des Steuerelements fest.

public:
 void SetValue(double value);
public void SetValue(double value);
abstract member SetValue : double -> unit
Public Sub SetValue (value As Double)

Parameter

value
Double

Der Wert, der festgelegt werden soll.

Ausnahmen

Ist value kleiner als das Minimum oder größer als der Maximalwert des Steuerelements.

Beispiele

Das folgende Beispiel zeigt eine mögliche Implementierung dieser Methode für ein benutzerdefiniertes Steuerelement. Das benutzerdefinierte Steuerelement zeigt seinen Bereichswert über den Alphawert der Basisfarbe an.

/// <summary>
/// Sets the value of the control.
/// </summary>
/// <param name="value">
/// The value to set the control to.
/// </param>
/// <remarks>
/// For the purposes of this sample, the custom control displays 
/// its value through the alpha setting of its base color.
/// </remarks>
public void SetValue(double value)
{
    if (value < Minimum | value > Maximum)
    {
        throw new ArgumentOutOfRangeException();
    }
    else
    {
        Color color = customControl.controlColor;
        // Invoke control method on separate thread to avoid 
        // clashing with UI.
        // Use anonymous method for simplicity.
        this.customControl.Invoke(new MethodInvoker(delegate()
        {
            customControl.controlColor =
                Color.FromArgb((int)value, color);
            customControl.Refresh();
        }));
    }
}
''' <summary>
''' Sets the value of the control.
''' </summary>
''' <param name="value">
''' The value to set the control to.
''' </param>
''' <remarks>
''' For the purposes of this sample, the custom control displays 
''' its value through the alpha setting of its base color.
''' </remarks>
Public Sub SetValue(ByVal value As Double) Implements IRangeValueProvider.SetValue
    If value < Minimum Or value > Maximum Then
        Throw New ArgumentOutOfRangeException()
    Else
        Dim color As Color = customControl.controlColor
        ' Invoke control method on separate thread to avoid 
        ' clashing with UI.
        ' Use anonymous method for simplicity.
        Me.customControl.Invoke(New MethodInvoker(Sub()
            customControl.controlColor = Color.FromArgb(CInt(Fix(value)), color)
            customControl.Refresh()
        End Sub))
    End If
End Sub

Hinweise

Der tatsächliche Wertsatz hängt von der Implementierung des Steuerelements ab. Das Steuerelement kann das angeforderte Auf- oder Abrunden.The control may round the requested value up or down.

Gilt für:

Weitere Informationen