Nella parte inferiore della MSDN RichTextBox di riferimento c'è un link per How to Extract the Text Content from a RichTextBox
E 'intenzione di assomigliare a questo:
public string RichTextBoxExample()
{
RichTextBox myRichTextBox = new RichTextBox();
// Create a FlowDocument to contain content for the RichTextBox.
FlowDocument myFlowDoc = new FlowDocument();
// Add initial content to the RichTextBox.
myRichTextBox.Document = myFlowDoc;
// Let's pretend the RichTextBox gets content magically ...
TextRange textRange = new TextRange(
// TextPointer to the start of content in the RichTextBox.
myRichTextBox.Document.ContentStart,
// TextPointer to the end of content in the RichTextBox.
myRichTextBox.Document.ContentEnd
);
// The Text property on a TextRange object returns a string
// representing the plain text content of the TextRange.
return textRange.Text;
}
fonte
2010-11-08 15:44:51
Perché utilizzare un RichTextBox, se si desidera che solo il testo? Non sarebbe meglio usare solo un TextBox invece? :) – Arcturus