SelectionItemPattern.Select 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
선택한 항목을 선택 취소한 다음 현재 요소를 선택합니다.
public:
void Select();
public void Select ();
member this.Select : unit -> unit
Public Sub Select ()
예제
다음 예제에서는 항목의 텍스트를 지정 하 여 컨테이너의 항목을 선택 하는 방법을 보여 줍니다.
///--------------------------------------------------------------------
/// <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 void SelectListItem(
AutomationElement selectionContainer, String itemText)
{
if ((selectionContainer == null) || (itemText == ""))
{
throw new ArgumentException(
"Argument cannot be null or empty.");
}
Condition propertyCondition = new PropertyCondition(
AutomationElement.NameProperty,
itemText,
PropertyConditionFlags.IgnoreCase);
AutomationElement firstMatch =
selectionContainer.FindFirst(TreeScope.Children, propertyCondition);
if (firstMatch != null)
{
try
{
SelectionItemPattern selectionItemPattern;
selectionItemPattern =
firstMatch.GetCurrentPattern(
SelectionItemPattern.Pattern) as SelectionItemPattern;
selectionItemPattern.Select();
}
catch (InvalidOperationException)
{
// Unable to select
return;
}
}
}
'''--------------------------------------------------------------------
''' <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