IRangeValueProvider.SetValue(Double) 메서드

정의

컨트롤의 값을 설정합니다.

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

매개 변수

value
Double

설정할 값입니다.

예외

value가 컨트롤의 최소값보다 작거나 최대값보다 큰 경우입니다.

예제

다음 예제에서는 사용자 지정 컨트롤에 대 한이 메서드의 가능한 구현을 보여 주세요. 사용자 지정 컨트롤은 기본 색의 알파 값을 통해 범위 값을 표시합니다.

/// <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

설명

설정 된 실제 값은 컨트롤 구현에 따라 달라 집니다. 컨트롤은 요청 value 된 위쪽 또는 아래쪽을 반올림할 수 있습니다.

적용 대상

추가 정보