MultipleViewPattern.SetCurrentView(Int32) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Define a vista atual específica do controlo.
public:
void SetCurrentView(int viewId);
public void SetCurrentView(int viewId);
member this.SetCurrentView : int -> unit
Public Sub SetCurrentView (viewId As Integer)
Parâmetros
- viewId
- Int32
Um identificador de vista específico para controlo.
Exceções
viewId não é membro da coleção de vistas suportada.
Exemplos
No exemplo seguinte, é recuperada a coleção de vistas disponíveis para um controlo que suporta o MultipleViewPattern padrão de controlo. Um membro da coleção de identificadores de vista é posteriormente usado para modificar a visão atual do controlo.
///--------------------------------------------------------------------
/// <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
Observações
Os identificadores de visualização podem ser recuperados usando GetSupportedViews.
A coleção específica de identificadores de vista de controlo é idêntica entre instâncias.