ISelectionProvider.GetSelection 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擷取每個子項目所選取的 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()
傳回
UI 自動化提供者的集合。
範例
下列範例會針對僅支援單一選取的清單框,顯示這個方法的其中一個可能實作。
/// <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 會傳回預設空陣列。