C# winform color, font dialog box control example

This article explains the use of C#winform color and font dialog controls

Create a winform project and add a button

 

 code show as below:

using System;
using System.Drawing;
using System.Windows.Forms;

namespace ColorDialogDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //颜色对话框
        private void button1_Click(object sender, EventArgs e)
        {
            ColorDialog cl = new ColorDialog();
            if (cl.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                button1.BackColor = Color.FromArgb(cl.Color.A, cl.Color.R, cl.Color.G, cl.Color.B);
            }
        }
        //字体对话框
        private void button2_Click(object sender, EventArgs e)
      

Guess you like

Origin blog.csdn.net/qq_30725967/article/details/132018840