1)在窗體上佈置控制元件:1個TextBox,1個Button和1 個ColorDialog
2)Form1.cs
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
public Form1()
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
if (colorDialog1.ShowDialog() == DialogResult.OK)
textBox1.BackColor = colorDialog1.Color;
1)在窗體上佈置控制元件:1個TextBox,1個Button和1 個ColorDialog
2)Form1.cs
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.BackColor = colorDialog1.Color;
}
}
}
}