C# rich text box styling

两盒软妹~` 提交于 2019-12-24 05:56:34

问题


I have some strings(paragraphs) coming from DB. I need to give each of the string a separate formatting like coloring, bold and italic etc. Problem is that I am restricted to use a single Rich text box.

What is the solution of my problem?

Thanks


回答1:


For each string you want to apply style to it, select the string and then apply the desired style. like:

richTextBox1.Text = "Hi this is a string";
richTextBox1.Select(0, 2);//selects Hi
richTextBox1.SelectionColor = Color.Red;//make its color red
richTextBox1.SelectionFont = new Font("Arial", 15, FontStyle.Bold); apply arial font to it and make it bold


来源:https://stackoverflow.com/questions/6840668/c-sharp-rich-text-box-styling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!