TextRange.Text Proprietà

Definizione

Ottiene o imposta il contenuto del testo normale della selezione corrente.

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

Valore della proprietà

String

Stringa che contiene il testo normale della selezione corrente.

Eccezioni

Si verifica quando viene effettuato un tentativo di impostazione della proprietà su null.

Esempio

Nell'esempio seguente viene illustrato l'uso della Text proprietà .

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

Commenti

Utilizzare questa proprietà per estrarre il contenuto di testo normale nella selezione corrente, indipendentemente da qualsiasi formattazione presente.

I nuovi caratteri di riga e le interruzioni di paragrafo vengono considerati equivalenti rispetto a questa proprietà. Qualsiasi tipo di interruzione di contenuto presente nella selezione corrente viene convertito in nuove righe quando questa proprietà viene letta.

Si applica a