我现在有以下代码:
var picker = new DateTimePicker();
var form = new Form();
form.Controls.Add(picker);
var result = form.ShowDialog();
if (result == DialogResult.OK)
{
//Can´t acces this
}
if (result == DialogResult.Cancel)
{
//Do when Form closed
}
当表单出现时,只有picker
它,没有按钮。现在我只能result == DialogResult.Cancel
在关闭表单时访问。我需要做什么才能访问分支result == DialogResult.OK