这是我到目前为止的代码:
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;
它应该不起作用吗?也许我选择了错误的事件?
答案 0 :(得分:2)
您应该在事件处理程序中而不是在外部创建Dialog,尝试这样的事情:
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;