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 将返回默认的空数组。