Setting font attributes for the Windows Forms RichTextBox Control

Source: Internet
Author: User

The Windows FormsRichTextBoxControl has numerous options for formatting the text it displays. you can make the selected characters bold, underlined, or italic, using the selectionfont property. you can also use this property to change the size and typeface of the selected characters. the selectioncolor property allows you to change the selected characters 'color.

To change the appearance of Characters

  • SetSelectionfontProperty to an appropriate font.

    To enable users to set the font family, size, and typeface in an application, you wowould typically useFontdialogComponent. For an overview, see Introduction to the Windows Forms fontdialog component.

  • SetSelectioncolorProperty to an appropriate color.

    To enable users to set the color in an application, you wocould typically useColordialogComponent. For an overview, see Introduction to the Windows Forms colordialog component.

    ' Visual Basic    RichTextBox1.SelectionFont = New Font("Tahoma", 12, FontStyle.Bold)    RichTextBox1.SelectionColor = System.Drawing.Color.Red    // C#    richTextBox1.SelectionFont = new Font("Tahoma", 12, FontStyle.Bold);    richTextBox1.SelectionColor = System.Drawing.Color.Red;    // C++    richTextBox1->SelectionFont =    new System::Drawing::Font("Tahoma", 12, FontStyle::Bold);    richTextBox1->SelectionColor = System::Drawing::Color::Red;

    NoteThese properties only affect selected text, or, if no text is selected, the text that is typed at the current location of the insertion point. for information on selecting text programmatically, see textboxbase. select method.

    See also

    RichTextBox class | RichTextBox Control (Windows Forms) | controls you can use on Windows Forms

Related Article

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.