C#富文本框样式 [英] C# rich text box styling

查看:318
本文介绍了C#富文本框样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些来自DB的字符串(段落)。我需要给每个字符串一个单独的格式,例如颜色,粗体和斜体等。问题是我只能使用单个Rich文本框。

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.

什么是解决我的问题?

谢谢

推荐答案

对于每个字符串您要对其应用样式,请选择字符串,然后应用所需的样式。像这样:

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

这篇关于C#富文本框样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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