TextPattern.GetVisibleRanges 메서드

정의

텍스트 컨테이너에서 각 텍스트 범위가 부분적으로 표시되는 첫 번째 줄로 시작되고 부분적으로 표시되는 마지막 줄의 끝까지 이어지는 서로 분리된 텍스트 범위의 배열을 검색합니다.

public:
 cli::array <System::Windows::Automation::Text::TextPatternRange ^> ^ GetVisibleRanges();
public System.Windows.Automation.Text.TextPatternRange[] GetVisibleRanges ();
member this.GetVisibleRanges : unit -> System.Windows.Automation.Text.TextPatternRange[]
Public Function GetVisibleRanges () As TextPatternRange()

반환

TextPatternRange[]

컨테이너 내의 표시되는 텍스트 범위 컬렉션이거나 빈 배열입니다. Null은 반환되지 않습니다.

예제

private TextPatternRange[] CurrentVisibleRanges(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;
    }
    return textpatternPattern.GetVisibleRanges();
}
Private Function CurrentVisibleRanges(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

    Return textpatternPattern.GetVisibleRanges()
End Function

설명

비연속 텍스트 범위 되거나 여러 열 레이아웃을 사용 하 여 텍스트 컨테이너에 하나 또는 더 많은 열이 스크롤되어 부분적으로 겹치는 창 또는 다른 개체에서 텍스트 컨테이너의 내용을 려 지 하는 경우 발생할 수 있습니다.

표시 되는 텍스트가 없는 경우 (비어 있음) 디 제너 레이트 텍스트 범위의 반환 됩니다. 텍스트 컨테이너 비어 있는 경우 또는 모든 텍스트 보기에서 스크롤 된 때이 빈 범위를 반환할 수 있습니다.

적용 대상

추가 정보