Compartir por


TextRange.Text Propiedad

Definición

Obtiene o establece el contenido de texto sin formato de la selección actual.

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

Valor de propiedad

Cadena que contiene el contenido de texto sin formato de la selección actual.

Excepciones

Se produce cuando se intenta establecer esta propiedad nullen .

Ejemplos

En el ejemplo siguiente se muestra el uso de la Text propiedad .

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

Comentarios

Utilice esta propiedad para extraer el contenido de texto sin formato en la selección actual, independientemente de cualquier formato que pueda estar presente.

Los nuevos caracteres de línea y saltos de párrafo se tratan como equivalentes con respecto a esta propiedad. Los tipos de saltos de contenido presentes en la selección actual se convierten en nuevas líneas cuando se lee esta propiedad.

Se aplica a