views:

323

answers:

1

I am writing a c# winforms application which needs to enable its users to add content to its interface. I have looked at the RichTextBox and the WebBrowser controls, but I'm not sure which route to take. The content would contain text with newlines and several tags that will include images which are in the project resources.

This is my text [niceimage] and it
includes an image and another: [smiley]

The disadvantage of the RichTextBox control is that I would need to craft richtext by hand which I am not familiar with. Also the .net framework does not have the functionality to make Metafiles from Images, the format RTF uses for embedding images.

The problems I had with the WebBrowser is that I have no idea how to load a page via a stream. I tried the DocumentStream to no avail. Also I need to include images which would need embedded images in the html string, which might not be supported. Another issue is that the WebBrowser control might be too heavy as the control will appear in several places in the application. It als needs to load very quickly for the application to feel snappy.

+2  A: 

You may want to look at the WPF RichTextBox which is supposed to be a major improvement over the .NET 2.0 version. Here's an article that elaborates upon the improvements.

Additionally, many Component development firms offer their own commercial version that has many feature and usability improvements. You may want to evaluate some of them, assuming that you are open to purchasing such a component. Try Googling for "RichTextBox component".

For the functionality that you require, I feel that using a WebBrowser (especially in multiple places in the application) would be overkill.

Cerebrus
Thanks the new WPF RichTextBox is indeed quite spiffy. It generates a FlowDocument which I can then in turn use to display in a FlowDocumentScrollViewer.
Wouter
Most welcome! It's my pleasure to introduce you both. ;-)
Cerebrus