110,537
社区成员
发帖
与我相关
我的任务
分享
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);
}
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); // 加粗且斜体下划线
}