C#字体的设置

/*
*程序的版权和版本声明部分:
*程序的版权和版本声明部分:
*Copyright(c)2013,烟台大学计算机学院学生
*All rights reserved.
*文件名称:
*作者:尚振伟
*完成日期:2014年11月6日
*版本号:v0.1
*对任务及求解方法的描述部分:
*输入描述:无
*问题描述:1)复选框中文字在左边;2)最下部为水平滚动条。水平滚动条最小值为4、最大值为72;且在窗体Load事件中通过代码设置;3)单击任何复选框,标签上文字样式都发生变化;4)单击任意单选按钮,标签上文字字体都发生改变;5)拖动水平滚动条,标签上文字大小发生变化
*程序输入:
*程序输出:
*问题分析:
*算法设计:
*我的程序:
*/
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 WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

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

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

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        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 radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            label1.Font = new Font("黑体",
                label1.Font.Size, label1.Font.Style);
        }

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

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

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


结果展示:

心得体会:下面滚动条的设计费了不少的功夫。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

尚振伟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值