选择隶书再勾选下划线,下划线没有反应,可是把隶书改成其它的字体,却能出现下划线,请问下边代码错在哪里?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace radiocheck复选框
{
public partial class radiocheck复选框 : Form
{
public radiocheck复选框()
{
InitializeComponent();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
//创建录书字体对象
if (radioButton1.Checked==true) //此句和if (radioButton1.Checked==true)功能是一样的."==true"可以取消吧,此看法有待论证
textBox1.Font = new Font("隶书", textBox1.Font.Size, textBox1.Font.Style);
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
//创建宋体字体对象
if (radioButton2.Checked == true) //可以不写"==true"
textBox1.Font = new Font("宋体", textBox1.Font.Size, textBox1.Font.Style);
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
//创建楷书_GB2312字体对象
if (radioButton3.Checked)//可以把"radioButton3.Checked"写成"radioButton3.Checked==true"
textBox1.Font = new Font("楷体_GB2312", textBox1.Font.Size, textBox1.Font.Style);
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
//创建粗体字型
if (checkBox1.Checked==true)//(checkBox1.Checked)也可以写成(checkBox1.Checked==true),意思一样,功能也一样
{
if (checkBox2.Checked && checkBox3.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Bold | FontStyle.Italic | FontStyle.Underline);
else if (checkBox2.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Bold | FontStyle.Italic);
else if (checkBox3.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Bold | FontStyle.Underline);
else
textBox1.Font = new Font(textBox1.Font, FontStyle.Bold);
}
else
{
if (checkBox2.Checked && checkBox3.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Italic | FontStyle.Underline);
else if (checkBox2.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Italic);
else if (checkBox3.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Underline);
else
textBox1.Font = new Font(textBox1.Font, FontStyle.Regular);
}
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
//创建斜体字型
if (checkBox2.Checked == true)
{
if (checkBox1.Checked && checkBox3.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Bold | FontStyle.Italic | FontStyle.Underline);
else if (checkBox1.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Bold | FontStyle.Italic);
else if (checkBox3.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Italic | FontStyle.Underline);
else
textBox1.Font = new Font(textBox1.Font, FontStyle.Italic);
}
else
{
if (checkBox1.Checked && checkBox3.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Bold | FontStyle.Underline);
else if (checkBox1.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Bold);
else if (checkBox3.Checked)
textBox1.Font = new Font(textBox1.Font, FontStyle.Underline);
else
textBox1.Font = new Font(textBox1.Font, FontStyle.Regular);
}
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
//创建下划线字型
if(checkBox3.Checked==true)
{
if(checkBox1.Checked&&checkBox2.Checked)
textBox1.Font=new Font(textBox1.Font,FontStyle.Bold|FontStyle.Italic|FontStyle.Underline);
else if(checkBox2.Checked)
textBox1.Font=new Font(textBox1.Font,FontStyle.Underline|FontStyle.Italic);
else if (checkBox1.Checked)
textBox1.Font=new Font(textBox1.Font,FontStyle.Bold|FontStyle.Underline);
else
textBox1.Font = new Font(textBox1.Font, FontStyle.Underline);
}
else
{
if(checkBox2.Checked&&checkBox1.Checked)
textBox1.Font=new Font(textBox1.Font,FontStyle.Bold|FontStyle.Italic);
else if(checkBox2.Checked)
textBox1.Font=new Font(textBox1.Font,FontStyle.Italic);
else if(checkBox1.Checked)
textBox1.Font=new Font(textBox1.Font,FontStyle.Bold);
else
textBox1.Font=new Font(textBox1.Font,FontStyle.Regular);
}
}
}
}
[此贴子已经被作者于2007-9-5 21:04:39编辑过]