如何在RichTextBox里面,实现加粗,斜体和下划线功能? 如何在RichTextBox里面,实现加粗,斜体和下划线功能?就是用户选定一段文字后,点击三个按钮,分别实现加粗,斜体和下划线功能。还有,C#做出来的程序,当字体同时有加粗,斜体和下划线格式。那么程序会不会出错? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void button1_Click(object sender, EventArgs e) { richTextBox1.SelectionFont = new Font(Font, FontStyle.Bold); // 加粗 } private void button2_Click(object sender, EventArgs e) { richTextBox1.SelectionFont = new Font(Font, FontStyle.Italic); // 斜体 } private void button3_Click(object sender, EventArgs e) { richTextBox1.SelectionFont = new Font(Font, FontStyle.Underline); // 下划线 } private void button4_Click(object sender, EventArgs e) { richTextBox1.SelectionFont = new Font(Font, FontStyle.Italic | FontStyle.Underline | FontStyle.Bold); // 加粗且斜体下划线 }当字体同时有加粗,斜体和下划线格式,不会出错 FontStyle fontStyle; private void button1_Click(object sender, EventArgs e) { fontStyle = (FontStyle)(fontStyle | FontStyle.Bold); SetFont(fontStyle); } private void button2_Click(object sender, EventArgs e) { fontStyle = (FontStyle)(fontStyle | FontStyle.Italic); SetFont(fontStyle); } private void button3_Click(object sender, EventArgs e) { fontStyle = (FontStyle)(fontStyle | FontStyle.Underline); SetFont(fontStyle); } private void SetFont(FontStyle style) { richTextBox1.SelectionFont = new Font("Arial",richTextBox1.SelectionFont.Size, fontStyle); } gisyellow,谢谢了。当时已经结帖了,没有看到你的帖子。不好意思。 求助求助。导出execl文件进度条的问题。 请教:反编译工具reflector怎么使用 单件模式在WEB开发中的一些疑问 普通的字符串怎么转换成十六进制字符串? BI商务智能 有段代码看不懂.求高手帮我看看.... Access能容纳多少条记录 联通SGIP长短信乱码 在后台动态添加boundfield列,readonly设为TRUE后就不能获得该列的值了 请问取整用 那个函数? 如何在保留RTF格式前提下,在RichTextBox里面添加换行符? 问一个系统稳定性的问题
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font(Font, FontStyle.Bold); // 加粗
} private void button2_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font(Font, FontStyle.Italic); // 斜体
} private void button3_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font(Font, FontStyle.Underline); // 下划线
} private void button4_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font(Font,
FontStyle.Italic | FontStyle.Underline | FontStyle.Bold); // 加粗且斜体下划线
}当字体同时有加粗,斜体和下划线格式,不会出错
FontStyle fontStyle;
private void button1_Click(object sender, EventArgs e)
{
fontStyle = (FontStyle)(fontStyle | FontStyle.Bold);
SetFont(fontStyle);
} private void button2_Click(object sender, EventArgs e)
{
fontStyle = (FontStyle)(fontStyle | FontStyle.Italic);
SetFont(fontStyle);
} private void button3_Click(object sender, EventArgs e)
{
fontStyle = (FontStyle)(fontStyle | FontStyle.Underline);
SetFont(fontStyle);
} private void SetFont(FontStyle style)
{
richTextBox1.SelectionFont = new Font("Arial",richTextBox1.SelectionFont.Size, fontStyle);
}