Partager via


TextRange.Text Propriété

Définition

Obtient ou définit le contenu de texte brut de la sélection actuelle.

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

Valeur de propriété

Chaîne contenant le contenu de texte brut de la sélection actuelle.

Exceptions

Se produit lorsqu’une tentative est effectuée pour définir cette propriété sur null.

Exemples

L’exemple suivant illustre l’utilisation de la Text propriété.

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

Remarques

Utilisez cette propriété pour extraire le contenu de texte brut dans la sélection actuelle, quelle que soit la mise en forme qui peut être présente.

Les nouveaux caractères de ligne et sauts de paragraphe sont traités comme équivalents par rapport à cette propriété. Tous les types de sauts de contenu présents dans la sélection actuelle sont convertis en nouvelles lignes lorsque cette propriété est lue.

S’applique à