TextRange.Contains(TextPointer) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Überprüft, ob sich eine Position (angegeben durch a TextPointer) innerhalb der aktuellen Auswahl befindet.
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
Parameter
- textPointer
- TextPointer
Eine Position, die zur Aufnahme in die aktuelle Auswahl getestet werden soll.
Gibt zurück
truewenn sich die angegebene Position innerhalb der aktuellen Markierung befindet; andernfalls . false
Ausnahmen
Tritt auf, wenn textPointer sich nicht im selben Dokument wie die aktuelle Auswahl befindet.
Beispiele
Im folgenden Beispiel wird die Verwendung der Contains-Methode gezeigt.
// 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
Hinweise
Positionen am Ende der aktuellen Auswahl (angegeben durch Start und End) werden als Teil der aktuellen Auswahl betrachtet.