RangeValuePattern.SetValue(Double) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
UI 자동화 요소와 연결된 값을 설정합니다.
public:
void SetValue(double value);
public void SetValue (double value);
member this.SetValue : double -> unit
Public Sub SetValue (value As Double)
매개 변수
- value
- Double
요소의 새 값입니다.
예외
value
가 요소의 최소값보다 작거나 최대값보다 큽니다.
예제
다음 예제에서는 AutomationElement 지는 RangeValuePattern 컨트롤 패턴에 컨트롤별 최소값으로 설정 된 해당 값입니다.
SetRangeValue(targetControl[0], rangeValuePattern.Current.Minimum);
SetRangeValue(targetControl(0), rangeValuePattern.Current.Minimum)
///--------------------------------------------------------------------
/// <summary>
/// Sets the range value of the control of interest.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <param name="rangeValue">
/// The value (either relative or absolute) to set the control to.
/// </param>
///--------------------------------------------------------------------
private void SetRangeValue(
AutomationElement targetControl,
double rangeValue)
{
if (targetControl == null)
{
throw new ArgumentException("Argument cannot be null.");
}
RangeValuePattern rangeValuePattern =
GetRangeValuePattern(targetControl);
if (rangeValuePattern.Current.IsReadOnly)
{
throw new InvalidOperationException("Control is read-only.");
}
try
{
rangeValuePattern.SetValue(rangeValue);
}
catch (ArgumentOutOfRangeException)
{
// TO DO: Error handling.
}
catch (ArgumentException)
{
// TO DO: Error handling.
}
}
'''--------------------------------------------------------------------
''' <summary>
''' Sets the range value of the control of interest.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <param name="rangeValue">
''' The value (either relative or absolute) to set the control to.
''' </param>
'''--------------------------------------------------------------------
Private Overloads Sub SetRangeValue( _
ByVal targetControl As AutomationElement, ByVal rangeValue As Double)
If targetControl Is Nothing Then
Throw New ArgumentException("Argument cannot be null.")
End If
Dim rangeValuePattern As RangeValuePattern = _
GetRangeValuePattern(targetControl)
If rangeValuePattern.Current.IsReadOnly Then
Throw New InvalidOperationException("Control is read-only.")
End If
Try
rangeValuePattern.SetValue(rangeValue)
Catch exc As ArgumentOutOfRangeException
' TO DO: Error handling.
Catch exc As ArgumentException
' TO DO: Error handling.
End Try
End Sub
///--------------------------------------------------------------------
/// <summary>
/// Obtains a RangeValuePattern control pattern from an
/// automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A RangeValuePattern object.
/// </returns>
///--------------------------------------------------------------------
private RangeValuePattern GetRangeValuePattern(
AutomationElement targetControl)
{
RangeValuePattern rangeValuePattern = null;
try
{
rangeValuePattern =
targetControl.GetCurrentPattern(
RangeValuePattern.Pattern)
as RangeValuePattern;
}
// Object doesn't support the
// RangeValuePattern control pattern
catch (InvalidOperationException)
{
return null;
}
return rangeValuePattern;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a RangeValuePattern control pattern from an
''' automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A RangeValuePattern object.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetRangeValuePattern( _
ByVal targetControl As AutomationElement) As RangeValuePattern
Dim rangeValuePattern As RangeValuePattern = Nothing
Try
rangeValuePattern = DirectCast( _
targetControl.GetCurrentPattern(rangeValuePattern.Pattern), _
RangeValuePattern)
Catch exc As InvalidOperationException
' Object doesn't support the
' RangeValuePattern control pattern
Return Nothing
End Try
Return rangeValuePattern
End Function 'GetRangeValuePattern
설명
설정 된 실제 값은 컨트롤 구현에 따라 달라 집니다. 컨트롤 요청 된 반올림할 수 value
또는 축소 합니다. UI 자동화 클라이언트를 검사할 수는 Value 실제 결정 하는 속성 값을 업데이트 합니다. 클라이언트 또한 속성에 속성 변경 이벤트를 등록 하 고 검사 이전 및 새 값으로 반환 된 AutomationPropertyChangedEventArgs합니다.