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;
- 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());
- }
When I try to add line 2 to my code, I get to richTexBox. but Document cannot be found when I type it.
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;
and I still cannot access richTextBox1.Document. I'm using Visual Stusio 2019 and am using .NET Framework 4.7.2.
How can I access richTextBox.Document?
Thanks for the help,
Bob Gatto