CentralServerDemo.ExRichTextBox.InsertTextAsRtf C# (CSharp) Method

InsertTextAsRtf() public method

Inserts the text using the given font, text, and highlight colors. The text is wrapped in RTF codes so that the specified formatting is kept. You can only assign valid RTF to the RichTextBox.Rtf property, else an exception is thrown. The RTF string should follow this format ... {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{[FONTS]}{\colortbl ;[COLORS]}} \viewkind4\uc1\pard\cf1\f0\fs20 [DOCUMENT AREA] }
NOTE: The text is inserted wherever the caret is at the time of the call, and if any text is selected, that text is replaced.
public InsertTextAsRtf ( string _text, Font _font, RtfColor _textColor, RtfColor _backColor ) : void
_text string
_font System.Drawing.Font
_textColor RtfColor
_backColor RtfColor
return void
        public void InsertTextAsRtf(string _text, Font _font, RtfColor _textColor, RtfColor _backColor) {

            StringBuilder _rtf = new StringBuilder();

            // Append the RTF header
            _rtf.Append(RTF_HEADER);

            // Create the font table from the font passed in and append it to the
            // RTF string
            _rtf.Append(GetFontTable(_font));

            // Create the color table from the colors passed in and append it to the
            // RTF string
            _rtf.Append(GetColorTable(_textColor, _backColor));

            // Create the document area from the text to be added as RTF and append
            // it to the RTF string.
            _rtf.Append(GetDocumentArea(_text, _font));

            this.SelectedRtf = _rtf.ToString();
        }

Same methods

ExRichTextBox::InsertTextAsRtf ( string _text ) : void
ExRichTextBox::InsertTextAsRtf ( string _text, Font _font ) : void
ExRichTextBox::InsertTextAsRtf ( string _text, Font _font, RtfColor _textColor ) : void