C#更改颜色和字体

时间:2019-12-04 10:51:23   收藏:0   阅读:277

实现效果

技术分享图片

 

1,窗口中添加colorDialog与fontDialog工具

技术分享图片
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Drawing2D;

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

        private void Button1_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog()==DialogResult.OK)
            {
                label1.ForeColor = colorDialog1.Color;
            }
        }

        private void Button2_Click(object sender, EventArgs e)
        {
            if (fontDialog1.ShowDialog()==DialogResult.OK)
            {
                label1.Font = fontDialog1.Font;
            }
        }
    }
}
App1

 

原文:https://www.cnblogs.com/Luck1996/p/11980745.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!