ColorDialog box

How a color is picked from the ColorDialog box?

E

Expert

Verified

In order to pick a color from color dialog box, it is required to create an instance of ColorDialog box and calls the ShowDialog() method. Code required to show the color dialog box and to set BackColor property of the Label control same as the color selected in the color dialog box control is:

private void button1_Click(object sender, EventArgs e)
{
 if (colorDialog1.ShowDialog() != DialogResult.Cancel)
 {
 label1.Text = "Here's my new color!";
 label1.BackColor = colorDialog1.Color;
 }
}

   Related Questions in DOT NET Programming

©TutorsGlobe All rights reserved 2022-2023.