Chinese garbled solution for RichTextBox extended control

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.