在richtextbox中使文本的第一行和最后两行应为粗体 [英] Make some first and last two lines of text should be bold in richtextbox

查看:118
本文介绍了在richtextbox中使文本的第一行和最后两行应为粗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的Windows应用程序(c#)中有一个包含5行文本的Richtextbox.
现在,我希望文本的前两行和后两行应为粗体.

任何帮助
问候...

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...

推荐答案

嗨Nagaraj,

希望这对您有帮助...

Hi Nagaraj,

Hope this will help you...

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!!!!!!!!!!!


这篇关于在richtextbox中使文本的第一行和最后两行应为粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆