IRangeValueProvider.SetValue(Double) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the value of the control.
public:
void SetValue(double value);
public void SetValue (double value);
abstract member SetValue : double -> unit
Public Sub SetValue (value As Double)
Parameters
- value
- Double
The value to set.
Exceptions
When value
is less than the minimum or greater than the maximum value of the control.
Examples
The following example shows one possible implementation of this method for a custom control. The custom control displays its range value through the alpha value of its base color.
/// <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
Remarks
The actual value set depends on the control implementation. The control may round the requested value
up or down.
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET