110,536
社区成员
发帖
与我相关
我的任务
分享
//设置粗体
private void button1_Click(object sender, EventArgs e)
{
Font bold = this.richTextBox1.SelectionFont;
if (bold.Bold)
{
if (bold.Italic)
{
if (bold.Underline)
{
this.richTextBox1.SelectionFont = new Font(bold, FontStyle.Italic | FontStyle.Underline);
}
else
this.richTextBox1.SelectionFont = new Font(bold, FontStyle.Italic);
}
else if (bold.Underline)
{
this.richTextBox1.SelectionFont = new Font(bold, FontStyle.Underline);
}
else
this.richTextBox1.SelectionFont = new Font(bold, FontStyle.Regular);
}
else if (bold.Italic)
{
if (bold.Underline)
{
this.richTextBox1.SelectionFont = new Font(bold, FontStyle.Bold | FontStyle.Italic | FontStyle.Underline);
}
else
this.richTextBox1.SelectionFont = new Font(bold, FontStyle.Bold | FontStyle.Italic);
}
else if (bold.Underline)
{
this.richTextBox1.SelectionFont = new Font(bold, FontStyle.Bold | FontStyle.Underline);
}
else
this.richTextBox1.SelectionFont = new Font(bold, FontStyle.Bold);
}