C#程序設計(二十六)----創建一個如下的窗體,並在窗體上放置一個標籤、一個按鈕、一個fontDialog控件

* 程序的版權和版本聲明部分
* Copyright (c) 2012, 煙臺大學計算機學院學生
* All rights reserved.

* 作 者: 劉鎮
* 完成日期: 2012 年 11 月 18 日
* 版 本 號: 3.026

* 對任務及求解方法的描述部分

* 問題描述:

1)程序運行時,單擊打開字體對話框按鈕,可選擇字體,並以所選字體作爲標籤字體。

*代碼部分:

 

 

 

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 Win10_5
{
    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;
        }
    }
}


 

測試結果:

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章