字体设置实验
错误:font =new(font.FontFamily,size);
实验代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace homework18
{
public partial class 字体设置 : Form
{
Font font;
public 字体设置()
{
InitializeComponent();
}
private void groupBox3_Enter(object sender, EventArgs e)
{
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
private void 字体设置_Load(object sender, EventArgs e)
{
comboBox1.Items.Clear();
for(int i=5;i<=72;i++)
{
comboBox1.Items.Add(i);
}
Font = richTextBox1.Font;
comboBox1.Text = Font.Size.ToString();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
FontStyle fontStyle1, fontStyle2, fontStyle3, fontStyle4;
fontStyle1 = FontStyle.Regular;
fontStyle2 = FontStyle.Regular;
fontStyle3 = FontStyle.Regular;
fontStyle4 = FontStyle.Regular;
if (checkBox1.Checked)
{
fontStyle1 = FontStyle.Bold;
}
if(checkBox2.Checked )
{
fontStyle2 = FontStyle.Italic;
}
if(checkBox3.Checked )
{
fontStyle3 = FontStyle.Underline;
}
if(checkBox4.Checked )
{
fontStyle4 = FontStyle.Strikeout;
}
font = new Font(font,fontStyle1|fontStyle2|fontStyle3|fontStyle4);
richTextBox1.Font = font;
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
Font的构造
Font( 字体名称 , 字号 )
Font( 字体名称 , 字号,字体风格 )
font.FontFamily不是个字体名称,用“宋体”等表示字体