Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a richtextbox with 5 lines of text in my windows application(c#).
Now,i want first two lines of text and last two lines of text should be bold.

any help
Regards...
Posted

1 solution

Hi Nagaraj,

Hope this will help you...

C#
private void button1_Click(object sender, EventArgs e)
       {
           MakeBold(richTextBox1.Lines[0].Split(' ')[0]);
           MakeBold(richTextBox1.Lines[1].Split(' ')[0]);
           MakeBold(richTextBox1.Lines[3].Split(' ')[0]);
           MakeBold(richTextBox1.Lines[4].Split(' ')[0]);
       }

       private void MakeBold(string text)
       {
           int index = richTextBox1.Find(text);
           richTextBox1.Select(index, text.Length);
           richTextBox1.SelectionFont = new Font(richTextBox1.Font, FontStyle.Bold);
       }



Thanks!!!!!!!!!!!
 
Share this answer
 
v2
Comments
[no name] 29-Aug-12 8:27am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900