TextRange.Contains(TextPointer) 메서드

정의

TextPointer로 지정된 위치가 현재 선택 영역 내에 있는지 여부를 확인합니다.

public:
 bool Contains(System::Windows::Documents::TextPointer ^ textPointer);
public bool Contains (System.Windows.Documents.TextPointer textPointer);
member this.Contains : System.Windows.Documents.TextPointer -> bool
Public Function Contains (textPointer As TextPointer) As Boolean

매개 변수

textPointer
TextPointer

현재 선택 영역에 포함되어 있는지 여부를 테스트할 위치입니다.

반환

Boolean

지정된 위치가 현재 선택 영역 내에 있으면 true이고, 그렇지 않으면 false입니다.

예외

textPointer 가 현재 선택 영역과 같은 문서에 없는 경우

예제

다음 예제에서는 Contains 메서드를 사용하는 방법을 보여 줍니다.

// This method returns true if two specified selections overlap, including when the
// end of one selection serves as the beginning of the other.
bool DoSelectionsOverlap(TextRange selection1, TextRange selection2)
{
    // Is either end of selection2 contained by selection1?
    if (selection1.Contains(selection2.Start) || selection1.Contains(selection2.End))
    {
        // If so, the selections overlap.
        return true;
    }
    // If not, selection2 may still entirely contain selection1.
    // Is either end of selection1 contained by seleciotn2?
    else if (selection2.Contains(selection1.Start) || selection2.Contains(selection1.End))
    {
        // If so, the selections overlap.
        return true;
    }
    // If neither selection contains the begging or end of the other selection, 
    //the selections do not overlap.
    else
    {
        return false;
    }
}
' This method returns true if two specified selections overlap, including when the
' end of one selection serves as the beginning of the other.
Private Function DoSelectionsOverlap(ByVal selection1 As TextRange, ByVal selection2 As TextRange) As Boolean
    ' Is either end of selection2 contained by selection1?
    If selection1.Contains(selection2.Start) OrElse selection1.Contains(selection2.End) Then
        ' If so, the selections overlap.
        Return True
        ' If not, selection2 may still entirely contain selection1.
        ' Is either end of selection1 contained by seleciotn2?
    ElseIf selection2.Contains(selection1.Start) OrElse selection2.Contains(selection1.End) Then
        ' If so, the selections overlap.
        Return True
        ' If neither selection contains the begging or end of the other selection, 
        'the selections do not overlap.
    Else
        Return False
    End If
End Function

설명

현재 선택 영역의 한쪽 끝에서 위치 (나타난 StartEnd) 현재 선택 영역의 일부로 간주 됩니다.

적용 대상