Partially Bold Text in RichTextBox

Introduction

In this blog, we will see how to partially bold text in RichTextBox.

Step 1: Create a new windows forms application.



Form1.cs

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Threading.Tasks;  
  9. using System.Windows.Forms;  
  10. namespace RichTextBox_BoldPartialText   
  11. {  
  12.     public partial class Form1: Form   
  13.     {  
  14.         public Form1()   
  15.         {  
  16.             InitializeComponent();  
  17.         }  
  18.         private void Form1_Load(object sender, EventArgs e)   
  19.         {  
  20.             for (int i = 0; i < 2; i++)   
  21.             {  
  22.                 string str = "Hello";  
  23.                 string str1 = "Hello1";  
  24.                 int length = richTextBox1.Text.Length;  
  25.                 richTextBox1.AppendText((((Convert.ToString((str + Convert.ToString(": "))) + str1) + "\r") + "\n"));  
  26.                 richTextBox1.Select(length, str.Length);  
  27.                 richTextBox1.SelectionFont = new Font(richTextBox1.Font, FontStyle.Bold);  
  28.             }  
  29.         }  
  30.     }  
  31. }  
RichTextBox



Output of the application looks like this



Summary

In this blog, we have seen how to partially bold text in RichTextBox.
Happy coding!
Ebook Download
View all
Learn
View all
MVC Corporation is consulting and IT services based company.