TextPatternRange.ScrollIntoView(Boolean) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
텍스트 범위가 뷰포트에 표시될 때까지 텍스트 컨트롤이 세로로 스크롤되도록 합니다.
public:
void ScrollIntoView(bool alignToTop);
public void ScrollIntoView(bool alignToTop);
member this.ScrollIntoView : bool -> unit
Public Sub ScrollIntoView (alignToTop As Boolean)
매개 변수
- alignToTop
- Boolean
true 텍스트 범위가 뷰포트의 맨 위로 플러시되도록 텍스트 컨트롤을 스크롤해야 하면 이고, false 뷰포트의 아래쪽으로 플러시해야 하는 경우
예외
컨트롤에서 스크롤을 지원하지 않는 경우
예제
private void ScrollToSelection(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;
}
TextPatternRange[] currentSelection = textpatternPattern.GetSelection();
currentSelection[0].ScrollIntoView(true);
}
Private Sub ScrollToSelection(ByVal target As AutomationElement)
' 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()
currentSelection(0).ScrollIntoView(True)
End Sub
설명
ScrollIntoView 는 숨겨진 텍스트와 표시되는 텍스트를 모두 적용합니다. UI 자동화 클라이언트는 IsHiddenAttribute 텍스트 표시 여부를 확인할 수 있습니다. 텍스트 범위가 숨겨지면 숨겨진 텍스트에 뷰포트에 앵커가 있는 경우에만 텍스트 컨트롤이 스크롤됩니다.