Aracılığıyla paylaş


MultipleViewPattern.SetCurrentView(Int32) Yöntem

Tanım

Geçerli denetime özgü görünümü ayarlar.

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

Parametreler

viewId
Int32

Denetime özgü görünüm tanımlayıcısı.

Özel durumlar

viewId desteklenen görünümler koleksiyonunun bir üyesi değildir.

Örnekler

Aşağıdaki örnekte, denetim desenini destekleyen MultipleViewPattern bir denetim için kullanılabilen görünüm koleksiyonu alınır. Görünüm tanımlayıcıları koleksiyonunun bir üyesi daha sonra denetimin geçerli görünümünü değiştirmek için kullanılır.

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

Açıklamalar

Görünüm tanımlayıcıları kullanılarak GetSupportedViewsalınabilir.

Denetime özgü görünüm tanımlayıcıları koleksiyonu örnekler arasında aynıdır.

Şunlara uygulanır