Jul 16
It’s easy to display an RTF file — that was embedded as a resource in a C# program — in a Windows Form RichTextControl.
First, include the following references:
using System.IO; using System.Reflection;
Next, load the RTF that you have embedded in your Visual Studio project:
Assembly asm = Assembly.GetExecutingAssembly(); Stream stream = asm.GetManifestResourceStream( "MyNamespace.FileName.rtf" ); RichTextBox rt = new RichTextBox(); rt.LoadFile( stream, RichTextBoxStreamType.RichText );
The trickiest part of loading an embedded resource is getting the correct path. Check out this article if you are having trouble loading the embedded resource.
I got this working, but my question is, how do I get it to pick up the bookmarks? I want to find the bookmarks and replace them with text I supply, so it’s some kind of parsing that needs to go on. But when I look at the rtf for the richtextbox, I don’t see the bookmarks.
The RichTextBox control does not support many of the advanced RTF features – sections, multiple pages, columns, bookmarks etc. – for this purpose you need to use a commercial control (like Nevron Rich Text Editor – http://www.nevron.com/Products.nevron-open-vision.rich-text-editor-control.aspx)