다음을 통해 공유


MultipleViewPattern.SetCurrentView(Int32) 메서드

정의

현재 컨트롤별 뷰를 설정합니다.

public:
 void SetCurrentView(int viewId);
public void SetCurrentView (int viewId);
member this.SetCurrentView : int -> unit
Public Sub SetCurrentView (viewId As Integer)

매개 변수

viewId
Int32

컨트롤별 뷰 식별자입니다.

예외

viewId가 지원되는 뷰 컬렉션의 멤버가 아닌 경우.

예제

다음 예제에서는 컬렉션 컨트롤에 대 한 사용 가능한 보기를 지 원하는 MultipleViewPattern 컨트롤 패턴 검색 됩니다. 뷰 식별자 컬렉션의 멤버는 컨트롤의 현재 뷰를 수정 하려면 이후에 사용 됩니다.

///--------------------------------------------------------------------
/// <summary>
/// Sets the current view of a target.
/// </summary>
/// <param name="multipleViewControl">
/// The current multiple view control.
/// </param>
/// <param name="viewID">
/// The view identifier from the supported views collection.
/// </param>
///--------------------------------------------------------------------
private void SetView(AutomationElement multipleViewControl, int viewID)
{
    if (multipleViewControl == null)
    {
        throw new ArgumentNullException(
            "AutomationElement parameter must not be null.");
    }

    // Get a MultipleViewPattern from the current control.
    MultipleViewPattern multipleViewPattern = 
        GetMultipleViewPattern(multipleViewControl);

    if (multipleViewPattern != null)
    {
        try
        {
            multipleViewPattern.SetCurrentView(viewID);
        }
        // viewID is not a member of the supported views collection
        catch (ArgumentException)
        {
            // TO DO: error handling
        }
    }
}
'/--------------------------------------------------------------------
'/ <summary>
'/ Sets the current view of a target.
'/ </summary>
'/ <param name="multipleViewControl">
'/ The current multiple view control.
'/ </param>
'/ <param name="viewID">
'/ The view identifier from the supported views collection.
'/ </param>
'/--------------------------------------------------------------------
Private Sub SetView( _
ByVal multipleViewControl As AutomationElement, _
ByVal viewID As Integer)
    If multipleViewControl Is Nothing Then
        Throw New ArgumentNullException( _
        "AutomationElement parameter must not be null.")
    End If

    ' Get a MultipleViewPattern from the current control.
    Dim multipleViewPattern As MultipleViewPattern = _
    GetMultipleViewPattern(multipleViewControl)

    If Not (multipleViewPattern Is Nothing) Then
        Try
            multipleViewPattern.SetCurrentView(viewID)
        Catch exc As ArgumentException
            ' viewID is not a member of the supported views collection
            ' TO DO: error handling
        End Try
    End If
End Sub

설명

뷰 식별자를 사용 하 여 검색할 수 GetSupportedViews입니다.

컨트롤별 보기 식별자 컬렉션 인스턴스에서 동일 합니다.

적용 대상