.net设置字体

Posted on 2010-11-16 20:56  严武  阅读(813)  评论(0)    收藏  举报

private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
   {
    //设置字体为宋体
    textBox1.Font=new Font("宋体",textBox1.Font.Size,textBox1.Font.Style);
   }

   private void radioButton4_CheckedChanged(object sender, System.EventArgs e)
   {
    //设置字体的大小为12
    textBox1.Font=new Font(textBox1.Font.FontFamily,12,textBox1.Font.Style);
   }

   private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
   {
    //设置字体的风格为加粗
    if(checkBox1.Checked)
     textBox1.Font=new Font(textBox1.Font,textBox1.Font.Style|FontStyle.Bold);
    else
     textBox1.Font=new Font(textBox1.Font,textBox1.Font.Style^FontStyle.Bold);
   }

   private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
   {
    //设置字体的风格为倾斜
if(checkBox2.Checked)
   textBox1.Font=new Font(textBox1.Font,textBox1.Font.Style|FontStyle.Italic);
else
   textBox1.Font=new Font(textBox1.Font,textBox1.Font.Style^FontStyle.Italic);
   }

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3