Reputation: 67
This is the code I have so far:
private void btnColour_Click(object sender, EventArgs e)
{
//show the colour dialog and check that user clicked ok
if (clrDialog.ShowDialog() == DialogResult.OK)
{
//save the colour that the user chose
c = clrDialog.Color;
}
}
Color c = Color.Black;
Isn't it supposed to be working? maybe I have selected the wrong event?
Upvotes: 4
Views: 4997
Reputation: 2794
You should create the Dialog in the event handler instead of outside, try something like this:
private void btnColour_Click(object sender, EventArgs e)
{
ColorDialog clrDialog = new ColorDialog();
//show the colour dialog and check that user clicked ok
if (clrDialog.ShowDialog() == DialogResult.OK)
{
//save the colour that the user chose
c = clrDialog.Color;
}
}
Color c = Color.Black;
Upvotes: 5