In the program there is a need to use RichTextBox to do some operations, inadvertently found in the CodeProject to encapsulate a more complete RichTextBox control (http://www.codeproject.com/KB/edit/ csexrichtextbox.aspx), the control package is still good, the Test interface effect is as follows:
In general, support the definition of various formats and the insertion of pictures, the effect is quite good, but in the actual use of the found in the code inserted in Chinese content will appear garbled.
Workaround One:
Because of its own application of RichTextBox and Rich Text format is not very familiar with the search for a long time to no avail, did not find a good solution, and later found that there is a more tricky way, is to reuse the RichTextBox mechanism to generate RTF document content, The rich-text format is then passed to the control implementation, as shown in the following code:
RichTextBox rtb = new RichTextBox();
rtb.Font = _font;
rtb.Text = _text;
AppendRtf(rtb.Rtf);
The above section of code is used to replace
public void InsertTextAsRtf(string _text, Font _font, RtfColor _textColor, RtfColor _backColor)
This in the function section. Selectedrtf = _rtf. ToString (); Can.