다음을 통해 공유


TextPatternRange.Select 메서드

정의

텍스트 컨트롤에서 텍스트 범위의 StartEnd 엔드포인트에 해당하는 텍스트를 강조 표시합니다.

public:
 void Select();
public void Select ();
member this.Select : unit -> unit
Public Sub Select ()

예외

텍스트 선택을 텍스트 컨트롤에서 지원하지 않을 때 발생합니다.

예제

private void SetSelection(AutomationElement target, String s, Boolean backward, Boolean ignorecase)
{
    // Specify the control type we're looking for, in this case 'Document'
    PropertyCondition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);

    // target --> The root AutomationElement.
    AutomationElement textProvider = target.FindFirst(TreeScope.Descendants, cond);

    TextPattern textpatternPattern = textProvider.GetCurrentPattern(TextPattern.Pattern) as TextPattern;

    if (textpatternPattern == null)
    {
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.");
        return;
    }
    TextPatternRange[] currentSelection = textpatternPattern.GetSelection();

    TextPatternRange tprText = currentSelection[0].FindText(s, backward, ignorecase);
    tprText.Select();
}
Private Sub SetSelection(ByVal target As AutomationElement, ByVal s As String, ByVal backward As Boolean, ByVal ignorecase As Boolean)
    ' Specify the control type we're looking for, in this case 'Document'
    Dim cond As PropertyCondition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)

    ' target --> The root AutomationElement.
    Dim textProvider As AutomationElement = target.FindFirst(TreeScope.Descendants, cond)

    Dim textpatternPattern As TextPattern = CType(textProvider.GetCurrentPattern(TextPattern.Pattern), TextPattern)

    If (textpatternPattern Is Nothing) Then
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.")
        Return
    End If
    Dim currentSelection As TextPatternRange() = textpatternPattern.GetSelection()
    Dim selectedText As TextPatternRange = currentSelection(0).FindText(s, backward, ignorecase)
    selectedText.Select()
End Sub

설명

텍스트 삽입 지점을 이동은 중복 제거 텍스트 범위를 제공 하는 경우는 Start 텍스트 범위 엔드포인트입니다.

적용 대상

추가 정보