TextRange.Text Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the plain text contents of the current selection.
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
Property Value
A string containing the plain text contents of the current selection.
Exceptions
Occurs when an attempt is made to set this property to null
.
Examples
The following example demonstrates the use of the Text property.
// 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
Remarks
Use this property to extract the plain text content in the current selection, regardless of any formatting that may be present.
New line characters and paragraph breaks are treated as equivalent with respect to this property. Any types of content breaks present in the current selection are converted to new lines when this property is read.
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
În curând: Pe parcursul anului 2024, vom elimina treptat Probleme legate de GitHub ca mecanism de feedback pentru conținut și îl vom înlocui cu un nou sistem de feedback. Pentru mai multe informații, consultați:Trimiteți și vizualizați feedback pentru