1)复选框中文字在左边;2)水平滚动条最小值为4、最大值为72;且在窗体Load事件中通过代码设置;3)单击任何复选框,标签上文字样式都发生变化;4)单击任意单选按钮,标签上文字字体都发生改变;5)拖

来源:互联网 发布:c语言 sleep 头文件 编辑:程序博客网 时间:2024/04/30 03:15

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text = "烟台大学";
            label1.AutoSize = true;
            label1.Font = new Font("宋体",48,FontStyle .Regular);
            hScrollBar1.Maximum = 72;
            hScrollBar1.Minimum = 4;
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            label1.Font = new Font(label1 .Font .Name ,label1.Font .Size ,checkBox1.Checked? label1.Font .Style |FontStyle .Italic:label1 .Font .Style ^(FontStyle .Italic) );
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            label1.Font = new Font(label1.Font.Name, label1.Font.Size, checkBox2.Checked ? label1.Font.Style | FontStyle.Underline: label1.Font.Style ^ (FontStyle.Underline));
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            label1.Font = new Font("楷体_GB2312",label1.Font.Size,label1.Font.Style);
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            label1.Font = new Font("宋体",label1.Font.Size,label1.Font.Style);
        }

        private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
        {
            label1.Font = new Font(label1 .Font.Name,hScrollBar1.Value,label1.Font.Style);
        }
    
    }
}

原创粉丝点击