Bagikan melalui


ISelectionProvider.GetSelection Metode

Definisi

Mengambil penyedia Automation UI untuk setiap elemen anak yang dipilih.

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

Mengembalikan

Kumpulan penyedia Automation UI.

Contoh

Contoh berikut menunjukkan satu kemungkinan implementasi metode ini untuk kotak daftar yang hanya mendukung satu pilihan.

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

Keterangan

Array kosong default dikembalikan oleh UIAutoCore.dll saat penyedia tidak menyediakan nilai.

Berlaku untuk

Lihat juga