Condividi tramite


StructureChangedEventArgs(StructureChangeType, Int32[]) Costruttore

Definizione

Inizializza una nuova istanza della StructureChangeType classe, specificando il tipo di modifica e l'identificatore (ID) dell'elemento la cui struttura è cambiata.

public:
 StructureChangedEventArgs(System::Windows::Automation::StructureChangeType structureChangeType, cli::array <int> ^ runtimeId);
public StructureChangedEventArgs (System.Windows.Automation.StructureChangeType structureChangeType, int[] runtimeId);
new System.Windows.Automation.StructureChangedEventArgs : System.Windows.Automation.StructureChangeType * int[] -> System.Windows.Automation.StructureChangedEventArgs
Public Sub New (structureChangeType As StructureChangeType, runtimeId As Integer())

Parametri

structureChangeType
StructureChangeType

Valore singolo che specifica il tipo di modifica.

runtimeId
Int32[]

Identificatore di runtime (ID) dell'elemento Automazione interfaccia utente la cui struttura è stata modificata.

Esempio

Nell'esempio seguente viene illustrato come costruire e generare un evento quando gli elementi figlio vengono aggiunti o rimossi da una casella di riepilogo personalizzata.

/// <summary>
/// Responds to an addition to the UI Automation tree structure by raising an event.
/// </summary>
/// <param name="list">
/// The list to which the item was added.
/// </param>
/// <remarks>
/// For the runtime Id of the item, pass 0 because the provider cannot know
/// what its actual runtime Id is.
/// </remarks>
public static void OnStructureChangeAdd(CustomListControl list)
{
    if (AutomationInteropProvider.ClientsAreListening)
    {
        int[] fakeRuntimeId = { 0 };
        StructureChangedEventArgs args =
            new StructureChangedEventArgs(StructureChangeType.ChildrenBulkAdded, 
            fakeRuntimeId);
        AutomationInteropProvider.RaiseStructureChangedEvent(
            (IRawElementProviderSimple)list.Provider, args);
    }
}

/// <summary>
/// Responds to a removal from the UI Automation tree structure 
/// by raising an event.
/// </summary>
/// <param name="list">
/// The list from which the item was removed.
/// </param>
/// <remarks>
/// For the runtime Id of the list, pass 0 because the provider cannot know
/// what its actual runtime ID is.
/// </remarks>
public static void OnStructureChangeRemove(CustomListControl list)
{
    if (AutomationInteropProvider.ClientsAreListening)
    {
        int[] fakeRuntimeId = { 0 };
        StructureChangedEventArgs args =
            new StructureChangedEventArgs(StructureChangeType.ChildrenBulkRemoved, 
            fakeRuntimeId);
        AutomationInteropProvider.RaiseStructureChangedEvent(
            (IRawElementProviderSimple)list.Provider, args);
    }
}
''' <summary>
''' Responds to an addition to the UI Automation tree structure by raising an event.
''' </summary>
''' <param name="list">
''' The list to which the item was added.
''' </param>
''' <remarks>
''' For the runtime Id of the item, pass 0 because the provider cannot know
''' what its actual runtime Id is.
''' </remarks>
Public Shared Sub OnStructureChangeAdd(ByVal list As CustomListControl)
    If AutomationInteropProvider.ClientsAreListening Then
        Dim fakeRuntimeId(1) As Integer
        fakeRuntimeId(0) = 0
        Dim args As New StructureChangedEventArgs( _
            StructureChangeType.ChildrenBulkAdded, fakeRuntimeId)
        AutomationInteropProvider.RaiseStructureChangedEvent( _
            CType(list.Provider, IRawElementProviderSimple), args)
    End If

End Sub


''' <summary>
''' Responds to a removal from the UI Automation tree structure by raising an event.
''' </summary>
''' <param name="list">
''' The list from which the item was removed.
''' </param>
''' <remarks>
''' For the runtime Id of the list, pass 0 because the provider cannot know
''' what its actual runtime ID is.
''' </remarks>
Public Shared Sub OnStructureChangeRemove(ByVal list As CustomListControl)
    If AutomationInteropProvider.ClientsAreListening Then
        Dim fakeRuntimeId(1) As Integer
        fakeRuntimeId(0) = 0
        Dim args As New StructureChangedEventArgs( _
            StructureChangeType.ChildrenBulkRemoved, fakeRuntimeId)
        AutomationInteropProvider.RaiseStructureChangedEvent( _
            CType(list.Provider, IRawElementProviderSimple), args)
    End If

End Sub

Commenti

I valori che possono essere restituiti dipendono structureChangeType dall'implementazione del provider di Automazione interfaccia utente. Ad esempio, quando gli elementi vengono aggiunti o rimossi da una casella di riepilogo Win32, se il provider non è in grado di determinare il numero di elementi aggiunti o rimossi, potrebbe specificare ChildrenInvalidated e non o ChildRemovedmeno ChildAdded .

Nella tabella seguente vengono descritte le informazioni ricevute dall'evento StructureChangedEventHandler per modifiche di struttura diverse.

structureChangeType Origine evento runtimeId
ChildAdded L'elemento figlio che è stato aggiunto. L'elemento figlio che è stato aggiunto.
ChildRemoved Padre del figlio rimosso. L'elemento figlio che è stato rimosso.
ChildrenBulkAdded Padre degli elementi figlio aggiunti. Padre degli elementi figlio aggiunti.
ChildrenBulkRemoved Padre degli elementi figlio rimossi. Padre degli elementi figlio rimossi.
ChildrenInvalidated Padre degli elementi figlio non validi. Padre degli elementi figlio non validi

I controlli personalizzati potrebbero non essere in grado di fornire un valore significativo in runtimeId. Per altre informazioni, vedere RaiseStructureChangedEvent.

Si applica a

Vedi anche