Simple way to return text from a RichTextBox (WPF)

Posted on 2008-02-11
Medium Priority
Last Modified: 2013-11-25
Is there a simple way to retrive the text from a RichTextBox in WPF using C#?  Maybe I'm missing something, but it seems awfully complicated.
Question by:fbk2000
1 Comment
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 20870969
There was always the Text property, but since a lot of things have changed, this is about all I can think of:

Some tricks for working with WPFs RichTextBox

private string GetText(RichTextBox richTextBox)
        // use a TextRange to fish out the Text from the Document
        TextRange textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);

        return textRange.Text;


Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question