I have a Windows Form (.NET Framework) with a rich text box and I want to store its data to a database. Through my research, the code I found was:
- string rtfText; //string to save to db
- TextRange tr = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
- using (MemoryStream ms = new MemoryStream())
- {
- tr.Save(ms, DataFormats.Rtf);
- rtfText = Encoding.ASCII.GetString(ms.ToArray());
- }
Now when I added a reference, I selected PresentationFramework, and at the top of my code, added the line:
- using System.Windows.Documents;
- using System.Windows.Controls;
How can I access richTextBox.Document?
Thanks for the help,
Bob Gatto

Sachin SinghPosted Dec 24, 2020, 4:15 PM
Amit GuptaPosted Dec 24, 2020, 4:12 PM
Bob GattoPosted Dec 24, 2020, 4:07 PM
Bob GattoPosted Dec 24, 2020, 3:36 PM
Sachin SinghPosted Dec 24, 2020, 3:26 PM
Amit GuptaPosted Dec 24, 2020, 3:05 PM