在窗体上放置一个标签、一个按钮、一个fontDialog控件。标签内容改为“烟台大学”。实现功能:1)程序运行时,单击打开字体对话框按钮,可选择字体,并以所选字体作为标签字体。

来源:互联网 发布:mac双系统默认启动设置 编辑:程序博客网 时间:2024/04/27 17:01
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 WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            //设置在颜色对话框中显示“颜色”选项
            fontDialog1.ShowColor = true;
            //设置包含应用按钮
            fontDialog1.ShowApply = true;
            fontDialog1.ShowDialog();
            label1.Font = fontDialog1.Font;
            label1.ForeColor = fontDialog1.Color;
        }
    }
}