ISelectionProvider.GetSelection Method

Definition

Retrieves a UI Automation provider for each child element that is selected.

C#
public System.Windows.Automation.Provider.IRawElementProviderSimple[] GetSelection();

Returns

A collection of UI Automation providers.

Examples

The following example shows one possible implementation of this method for a list box that supports only single selection.

C#
/// <summary>
/// Returns the UI Automation provider for the selected list items.
/// </summary>
/// <returns>The selected items.</returns>
/// <remarks>
/// Because this is a single-selection list box, only one item is 
/// returned.
/// </remarks>
IRawElementProviderSimple[] ISelectionProvider.GetSelection()
{
    int index = OwnerListControl.SelectedIndex;
    return new IRawElementProviderSimple[] { GetProviderForIndex(index) };
}

Remarks

A default empty array is returned by UIAutoCore.dll when the provider doesn't supply a value.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also