问题
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