Freigeben über


TextRange.Text Eigenschaft

Definition

Dient zum Abrufen oder Festlegen des Nur-Text-Inhalts der aktuellen Auswahl.

public:
 property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public string Text { get; set; }
member this.Text : string with get, set
Public Property Text As String

Eigenschaftswert

Eine Zeichenfolge, die den Nur-Text-Inhalt der aktuellen Auswahl enthält.

Ausnahmen

Tritt auf, wenn versucht wird, diese Eigenschaft auf .null

Beispiele

Im folgenden Beispiel wird die Verwendung der Text Eigenschaft veranschaulicht.

// This method returns a plain text representation of a specified FlowDocument.
string GetTextFromFlowDocument(FlowDocument flowDoc)
{
     // Create a new TextRanage that takes the entire FlowDocument as the current selection.
     TextRange flowDocSelection = new TextRange(flowDoc.ContentStart, flowDoc.ContentEnd);
      
     // Use the Text property to extract a string that contains the unformatted text contents 
     // of the FlowDocument.
     return flowDocSelection.Text;
}
' This method returns a plain text representation of a specified FlowDocument.
Private Function GetTextFromFlowDocument(ByVal flowDoc As FlowDocument) As String
    ' Create a new TextRanage that takes the entire FlowDocument as the current selection.
    Dim flowDocSelection As New TextRange(flowDoc.ContentStart, flowDoc.ContentEnd)

    ' Use the Text property to extract a string that contains the unformatted text contents 
    ' of the FlowDocument.
    Return flowDocSelection.Text
End Function

Hinweise

Verwenden Sie diese Eigenschaft, um den Nur-Text-Inhalt in der aktuellen Auswahl zu extrahieren, unabhängig von formatierungen, die möglicherweise vorhanden sind.

Neue Zeilen- und Absatzumbrüche werden in Bezug auf diese Eigenschaft als gleichwertig behandelt. Alle Inhaltsumbrüche, die in der aktuellen Auswahl vorhanden sind, werden in neue Zeilen konvertiert, wenn diese Eigenschaft gelesen wird.

Gilt für: