次の方法で共有


StructureChangedEventArgs(StructureChangeType, Int32[]) コンストラクター

定義

変更の種類と、構造体が StructureChangeType 変更された要素の識別子 (ID) を指定して、クラスの新しいインスタンスを初期化します。

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())

パラメーター

structureChangeType
StructureChangeType

変更の種類を指定する単一の値。

runtimeId
Int32[]

構造体が変更されたUI オートメーション要素のランタイム識別子 (ID)。

次の例は、子がカスタム リスト ボックスに追加または削除されたときにイベントを構築して発生させる方法を示しています。

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

注釈

structureChangeTypeすことができる値は、UI オートメーション プロバイダーの実装によって異なります。 たとえば、Win32 リスト ボックスに項目を追加または削除する場合、プロバイダーが追加または削除された項目の数を決定できない場合、指定または削除されないChildAdded場合ChildRemovedがありますChildrenInvalidated

次の表では、さまざまな構造体の変更に対して受信したイベントの StructureChangedEventHandler 情報について説明します。

structureChangeType [イベント ソース] と置き換えます。 runtimeId
ChildAdded 追加された子。 追加された子。
ChildRemoved 削除された子の親。 削除された子。
ChildrenBulkAdded 追加された子の親。 追加された子の親。
ChildrenBulkRemoved 削除された子の親。 削除された子の親。
ChildrenInvalidated 無効にされた子の親。 無効にされた子の親

カスタム コントロールで意味のある値 runtimeIdを指定できない場合があります。 詳細については、「RaiseStructureChangedEvent」を参照してください。

適用対象

こちらもご覧ください