本文讲解C#winform颜色、字体对话框控件的使用
创建winform项目,添加按钮
代码如下:
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)