TextPatternRange.FindText(String, Boolean, Boolean) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 텍스트가 포함된 텍스트 범위 하위 집합을 반환합니다.
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입니다(Nothing Visual Basic).
예제
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 .