TextRange.Text Tulajdonság

Definíció

Lekéri vagy beállítja az aktuális kijelölés egyszerű szöveges tartalmát.

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

Tulajdonság értéke

Az aktuális kijelölés egyszerű szöveges tartalmát tartalmazó sztring.

Kivételek

A tulajdonság beállítására tett kísérlet során a következőre nulltörténik: .

Példák

Az alábbi példa a tulajdonság használatát Text mutatja be.

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

Megjegyzések

Ezzel a tulajdonságmal kinyerheti az egyszerű szöveges tartalmat az aktuális kijelölésben, függetlenül attól, hogy bármilyen formázás szerepel-e a kijelölésben.

Az új sorkarakterek és bekezdéstörések ezzel a tulajdonsággal egyenértékűként lesznek kezelve. Az aktuális kijelölésben található tartalomtörések minden típusa új sortá alakul a tulajdonság beolvasásakor.

A következőre érvényes: