C # indicates the upper or subscript of the text in RichTextBox

Source: Internet
Author: User

The following describes how to set the SelectionCharOffset attribute of the upper and lower mark in RichTextBox. The SelectionCharOffset attribute is based on the string representation of the normal baseline and is used to set the painting element. If you want to set it as a positive number when you move the cursor to the upper mark, you want to set it as a negative number when you move the cursor to the lower mark.

In the following example, "H2O (Note 1)" is generated by setting the painting element.

 

[C #] // RichTextBox clears richTextBox1.Clear (); // the letter "H" is usually set to richTextBox1.SelectedText = "H ";
// Number "2" is set to 5 elements under the baseline
RichTextBox1.SelectionCharOffset =-5; richTextBox1.SelectedText = "2"; // The letter "O" is also usually set to richTextBox1.SelectionCharOffset = 0; richTextBox1.SelectedText = "O"; // "(Note 1) "set to baseline line 5 painter richTextBox1.SelectionCharOffset = 5; richTextBox1.SelectedText =" (Note 1) "; // The letter" O "is also usually set to richTextBox1.SelectionCharOffset = 0; [VB] Real-time upper and lower standard form in RichTextBox Controller
---- VB provides a superior control component RichTextBox, which we can use to implement various editing methods in this document. The following steps form the upper and lower labels in the RichTextBox controls, the main character is to make the scale of the character used as the top or bottom mark a little smaller, and the bit is set to float on the base line. SelCharOffset, which determines that the text in the RichTextBox controller is displayed on the base line (
Normal State). When SelCharOffset is greater than 0, the text is displayed on the base line and becomes the upper standard form;
---- When SelCharOffset is less than 0, the text is displayed under the baseline and becomes the lower standard.

---- This property is ineffective in design.

---- Add the following code to the Load event of the table ticket:

Private Sub Form_Load ()
RichTextBox1.Font. Name = "Times New Roman"
RichTextBox1.Font. Size = 10
RichTextBox1.Text = "sulfuric acid"
Note: Move the numbers down 2 points.
OffsetRichText RichTextBox1, 1, 1, 2
OffsetRichText RichTextBox1, 4, 1,-2
End Sub

Private Sub OffsetRichText (box As RichTextBox, start As Integer, length As Integer, offset As Integer)
Note: box refers to the RichTextBox Control; start refers to the upper and lower mark.
Note: the starting position of the character; length indicates the length of the upper and lower mark characters;
Note: offset indicates whether to supermark or subscript. It must be greater than 0 and smaller than 0.
Box. SelStart = start
Box. SelLength = length
Box. SelFontSize = box. Font. Size-abs (offset)
Box. SelCharOffset = ScaleY (offset, vbPoints, vbTwips)
Box. SelStart = 0
Box. SelLength = 0
End Sub
This program is successfully debugged on VB4/32 and VB5. Finally, in RichTextBox
The string in the control is in the format.

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.