我有一些来自DB的字符串(段落)。我需要给每个字符串一个单独的格式,如着色,粗体和斜体等。问题是我被限制使用一个Rich文本框。
我的问题的解决方案是什么?
由于
答案 0 :(得分:1)
对于要为其应用样式的每个字符串,请选择字符串,然后应用所需的样式。像:
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