次の方法で共有


ISelectionProvider.GetSelection メソッド

定義

選択されている各子要素の UI オートメーション プロバイダーを取得します。

public:
 cli::array <System::Windows::Automation::Provider::IRawElementProviderSimple ^> ^ GetSelection();
public System.Windows.Automation.Provider.IRawElementProviderSimple[] GetSelection ();
abstract member GetSelection : unit -> System.Windows.Automation.Provider.IRawElementProviderSimple[]
Public Function GetSelection () As IRawElementProviderSimple()

戻り値

IRawElementProviderSimple[]

UI オートメーション プロバイダーのコレクション。

次の例は、1 つの選択のみをサポートするリスト ボックスに対して、このメソッドの 1 つの実装が可能であることを示しています。

/// <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) };
}
''' <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>
Private Function GetSelection() As IRawElementProviderSimple() Implements ISelectionProvider.GetSelection
    Dim index As Integer = OwnerListControl.SelectedIndex
    Return New IRawElementProviderSimple() { GetProviderForIndex(index) }
End Function

注釈

既定の空の配列は、プロバイダーが値を指定しない場合にUIAutoCore.dllによって返されます。

適用対象

こちらもご覧ください