TextRange.Text Egenskap

Definition

Hämtar eller anger oformaterad text i den aktuella markeringen.

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

Egenskapsvärde

En sträng som innehåller oformaterad text i den aktuella markeringen.

Undantag

Inträffar när ett försök görs att ange den här egenskapen till null.

Exempel

I följande exempel visas hur egenskapen används Text .

// 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

Kommentarer

Använd den här egenskapen för att extrahera oformaterad text i den aktuella markeringen, oavsett vilken formatering som kan finnas.

Nya radtecken och styckebrytningar behandlas som likvärdiga med den här egenskapen. Alla typer av innehållsbrytningar som finns i den aktuella markeringen konverteras till nya rader när den här egenskapen läse.

Gäller för