RichTextBox, manipulating RTF directly
-
Hi there. In order to create a class for a chat application - like readonly textbox that inherits the System.Windows.Forms.RichTextBox, I am trying to use a predefined color table (IRC-like textbox) in the RTF code.
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Fixedsys;}} {\colortbl ;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue139;\red0\green100\blue0;\red255\green0\blue0;\red128\green0\blue0;\red128\green0\blue128;\red255\green165\blue0;\red255\green255\blue0;\red144\green238\blue144;\red95\green158\blue160;\red0\green255\blue255;\red0\green0\blue255;\red255\green192\blue203;\red169\green169\blue169;} "\viewkind4\uc\pard\f1\highlight1\cf2 This line uses the first color as foreground- and the second color as background-color on this line\par \highlight0\cf0 This line uses default colors.}
After I set the new RichText (control.RTF = variable), the RichTextBox automatically reformats the raw rich text I manipulated just a few ticks ago. It removes all not yet used colors from the colortable and even reorders it. Is there a way to override/avoid automatic reformatting of the raw richtext (control.RTF)? I don't want to use the techinque where the last added text is selected, some forecolor applied, via API some background color applied, ... Daniel