How to Make Specific Text in a String Bold in Visual Studio C# 2008 Using a RichTextBox

Posted on 2011-10-26
Last Modified: 2013-12-16
I am attempting to write a RichTextBox and I need to be able to write part of a sentence in bold and the remainder of the text in the sentence in regular type. Could someone help me figure out what the syntax would be in order to complete this task? For instance, if the control was called RichTextBox1 and the sentence was "The dog crossed the road", how would I get the word "dog" to be bold and the remainder of the sentence to be regular type?

Any help that could be provided on this topic would be greatly appreciated.
Question by:thenthorn1010
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    LVL 74

    Accepted Solution

    Using the code I posted in your other question, change line 6 to:

    richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, FontStyle.Bold);

    Open in new window

    LVL 74

    Expert Comment

    by:käµfm³d 👽
    The question is slightly different.
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Ah...I see.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now