Christopher Krause

Christopher Krause

  • NA
  • 24
  • 57.6k

Typical problems with the .NET RichTextBox control

Jul 6 2011 8:53 AM
The Microsoft RichTextBox control that ships with the .NET Framework offers basic word processing. But as soon as you want more than just basic typing-text-in-a-box functionality, the control quickly reaches its limits. You are forced to deploy workarounds for simple tasks, such as printing. This article summarizes some of the typical problems you will face when using the RichTextBox.

Printing and print preview

There is no built-in printing functionality in the standard RichTextBox. Pages of custom code are required to print richly formatted content in the edit control, or to display multiple pages in a print preview control.

TX Text Control .NET Express: Using TX Text Control .NET Express, printing is done with one line of code:

textControl1.Print("Print job name");

Load MS Word compatible documents

RTF is a very common format, which is used as the clipboard format when copying content from Microsoft Word to other applications that support rich text. Feature-wise, RTF is similar to the DOC or DOCX format - it is represented by textual tags, just like HTML.

When loading or pasting RTF from Microsoft Word into the RichTextBox, a lot of formatting is lost: Headers and footers disappear, as do various page formats, section breaks and complex tables.

TX Text Control .NET Express: Using TX Text Control .NET Express, you can easily drag and drop, or load content from Microsoft Word into your own applications without loosing any formatting.

Mail-merge fields

In order to build mail-merge applications, you have to insert placeholders into your templates and then replace them with data from various data sources. Using the Visual Studio RichTextBox, text-based, unique placeholders are required that must be located using the Find method and then replaced with text. This is a very slow and inflexible way of implementing mail-merge applications.

TX Text Control .NET Express: TX Text Control .NET Express provides a TextFieldCollection that can be used to iterate through TextFields in order to replace their text. Each field has an ID, a unique name property, flexible events and can be protected to avoid changes or deletions.

Update your RichTextBox today!

Upgrade your Microsoft Visual Studio toolbox with a true WYSIWYG rich text editor, including printing, print preview and full table support, with TX Text Control .NET Express.

TX Text Control .NET Express is completely free of charge.

More information: TX Text Control .NET Express


About TX Text Control:

TX Text Control was originally released in 1991, since then more than 50,000 copies have been sold. Starting off as a single, small DLL, TX Text Control has made its way through 16-bit DLL and VBX versions to today's Enterprise edition with its .NET and ActiveX components. The recent addition to the family, TX Text Control .NET Server, offers all of TX Text Control advanced word processing functionality in an easy-to-use server-side .NET component. Customers benefit from these years of experience, large user base, and at the same time, appreciate developing with a mature, reliable product.

Contact Informations:

[email protected]

North & South America:
Phone: +1 704-370-0110
Phone: +1 877-462-4772 (toll free)

Europe:
Phone: +49 (0)421 42 70 67 10

Asia Pacific:
Phone: +886 2-2797-8508

Answers (1)