效果:
代码:
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.SelectionColor = Color.Blue;
}
private void button2_Click(object sender, EventArgs e)
{
richTextBox1.SelectionColor = Color.Red;
}
private void button3_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font("雅黑", 18);
}
private void button4_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font("隶书", 20);
}
private void button5_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font("楷体", 23);
}
private void button6_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font("黑体", 22);
}
private void button7_Click(object sender, EventArgs e)
{
richTextBox1.SelectionBullet = true;
}
private void button8_Click(object sender, EventArgs e)
{
richTextBox1.SelectionBackColor = Color.Gray;
}
private void button9_Click(object sender, EventArgs e)
{
richTextBox1.SelectionFont = new Font("宋体", richTextBox1.Font.Size);
richTextBox1.SelectionColor = Color.Black;
richTextBox1.SelectionBullet = false;
richTextBox1.SelectionBackColor = Color.White;
}
本文介绍了一个使用 C# 编写的简单应用程序中如何通过按钮点击事件来改变 RichTextBox 控件中文本的颜色、字体和背景色等样式。此外还包含了如何设置项目符号的功能。
607

被折叠的 条评论
为什么被折叠?



