SelectionItemPattern.ElementSelectedEvent Field

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Identifies the event that is raised when a call to any of Select, AddToSelection, or RemoveFromSelection results in a single item being selected.

Namespace:   System.Windows.Automation
Assembly:  UIAutomationClient (in UIAutomationClient.dll)

Public Shared ReadOnly ElementSelectedEvent As AutomationEvent

This identifier is used by UI Automation client applications. UI Automation providers should use the equivalent field in SelectionItemPatternIdentifiers.

In the following example, event listeners are declared for the SelectionItemPattern events.

'''--------------------------------------------------------------------
''' <summary>
''' Subscribe to the selection item events of interest.
''' </summary>
''' <param name="selectionItem">
''' Automation element that supports SelectionItemPattern and is 
''' a child of a selection container that supports SelectionPattern
''' </param>
''' <remarks>
''' The events are raised by the SelectionItem elements, 
''' not the Selection container.
''' </remarks>
'''--------------------------------------------------------------------
Private Sub SetSelectionEventHandlers( _
ByVal selectionItem As AutomationElement)
    Dim selectionHandler As AutomationEventHandler = _
    New AutomationEventHandler(AddressOf OnSelectionHandler)

    Automation.AddAutomationEventHandler( _
    SelectionItemPattern.ElementSelectedEvent, _
    selectionItem, TreeScope.Element, selectionHandler)
    Automation.AddAutomationEventHandler( _
    SelectionItemPattern.ElementAddedToSelectionEvent, _
    selectionItem, TreeScope.Element, selectionHandler)
    Automation.AddAutomationEventHandler( _
    SelectionItemPattern.ElementRemovedFromSelectionEvent, _
    selectionItem, TreeScope.Element, selectionHandler)
End Sub 'SetSelectionEventHandlers


Private Sub OnSelectionHandler(ByVal src As Object, ByVal e As AutomationEventArgs)
    ' TODO: event handling
End Sub 'SelectionHandler

.NET Framework
Available since 3.0
Return to top
Show: