TextRange.Text Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur isi teks biasa dari pilihan saat ini.
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
Nilai Properti
String yang berisi isi teks biasa dari pilihan saat ini.
Pengecualian
Terjadi ketika upaya dilakukan untuk mengatur properti ini ke null.
Contoh
Contoh berikut menunjukkan penggunaan Text properti.
// 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
Keterangan
Gunakan properti ini untuk mengekstrak konten teks biasa dalam pilihan saat ini, terlepas dari pemformatan apa pun yang mungkin ada.
Karakter baris baru dan hentian paragraf diperlakukan setara sehubungan dengan properti ini. Tipe hentian konten apa pun yang ada dalam pilihan saat ini dikonversi ke baris baru saat properti ini dibaca.