本文整理汇总了VB.NET中System.Windows.Automation.SelectionItemPattern.Select方法的典型用法代码示例。如果您正苦于以下问题:VB.NET SelectionItemPattern.Select方法的具体用法?VB.NET SelectionItemPattern.Select怎么用?VB.NET SelectionItemPattern.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了SelectionItemPattern.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: SelectListItem
'''--------------------------------------------------------------------
''' <summary>
''' Selects a string item in a container.
''' </summary>
''' <param name="selectionContainer">The selection container.</param>
''' <param name="itemText">The text to select.</param>
''' <remarks>
''' This deselects any currently selected items.
''' To add the item to the current selection in a multiselect list,
''' use AddToSelection instead of Select.
''' </remarks>
'''--------------------------------------------------------------------
Public Sub SelectListItem( _
ByVal selectionContainer As AutomationElement, ByVal itemText As String)
If selectionContainer Is Nothing OrElse itemText = "" Then
Throw New ArgumentException("Argument cannot be null or empty.")
End If
Dim propertyCondition = _
New PropertyCondition(AutomationElement.NameProperty, _
itemText, PropertyConditionFlags.IgnoreCase)
Dim firstMatch As AutomationElement = _
selectionContainer.FindFirst(TreeScope.Children, propertyCondition)
If Not (firstMatch Is Nothing) Then
Try
Dim selectionItemPattern As SelectionItemPattern
selectionItemPattern = DirectCast( _
firstMatch.GetCurrentPattern(selectionItemPattern.Pattern), _
SelectionItemPattern)
selectionItemPattern.Select()
Catch
' Unable to select
Return
End Try
End If
End Sub