Share via


TextPatternRange.FindText(String, Boolean, Boolean) 메서드

정의

지정된 텍스트를 포함하는 텍스트 범위 하위 집합을 반환합니다.

public:
 System::Windows::Automation::Text::TextPatternRange ^ FindText(System::String ^ text, bool backward, bool ignoreCase);
public System.Windows.Automation.Text.TextPatternRange FindText (string text, bool backward, bool ignoreCase);
member this.FindText : string * bool * bool -> System.Windows.Automation.Text.TextPatternRange
Public Function FindText (text As String, backward As Boolean, ignoreCase As Boolean) As TextPatternRange

매개 변수

text
String

검색할 텍스트 문자열입니다.

backward
Boolean

마지막으로 나타나는 텍스트 범위를 반환해야 하면 true이고, 처음으로 나타나는 텍스트 범위를 반환해야 하면 false입니다.

ignoreCase
Boolean

대/소문자를 구분하지 않으면 true이고, 그렇지 않으면 false입니다.

반환

지정된 텍스트와 일치하는 텍스트 범위이거나, 이러한 범위가 없으면 null(Visual Basic의 경우 Nothing)입니다.

예제

 private TextPatternRange TextFromSelection(AutomationElement target)
{
    // 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 null;
    }
    TextPatternRange[] tprSelection = textpatternPattern.GetSelection();
    // Find 'text' in selection range
    return tprSelection[0].FindText("text", false, true);
}
Private Function TextFromSelection(ByVal target As AutomationElement) As TextPatternRange
    ' 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 Nothing
    End If
    Dim currentSelection As TextPatternRange() = textpatternPattern.GetSelection()
    ' Find 'text' in selection range
    Return currentSelection(0).FindText("text", False, True)
End Function

설명

숨겨진 / 표시 텍스트에 차이가 없습니다 있습니다. UI 자동화 클라이언트가 사용할 수 IsHiddenAttribute 텍스트 표시 여부를 확인 합니다.

참고

사용 하 여 DocumentRange 전체 문서를 검색 합니다.

적용 대상

추가 정보