Add the text area to C # And the text size

Source: Internet
Author: User

Recently, when I was working on a project, I encountered the need to perform the upper and lower mark processing in the text box. The simple text control textbox cannot meet this function and must be implemented using the Rich Text control RichTextBox. The specific effect is as follows:

Before setting the upper font size: After setting the upper font size

SpecificCodeAs follows:

This. richtextbox1.selectedtext = "mm ";
This. richtextbox1.selectionfont = new font ("", 8, fontstyle. Regular );
This. richtextbox1.selectioncharoffset = 3; // The pixel of the displacement. The positive value is the move up, and the negative value is the move down.
This. richtextbox1.selectedtext = "2 ";

The code is very simple, but there is a note: This. richtextbox1.selectionfont = new font ("", 8, fontstyle. regular); the location of this line of code is critical. If it is displayed on the last line or the first line, the font size of the entire richtextbox1 is 8, and the entire display is small. If it is not set, the default font is font 10. The 2 above is displayed, as shown in figure.

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.