我如何检查是否在消息框中单击了是 [英] how do i check if yes has been clicked on a message box
本文介绍了我如何检查是否在消息框中单击了是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以教我如何确定是否在消息框中单击了是"或否"吗?我的代码如下所示:
Can anyone teach me how i can determine if ''yes'' or ''no'' has been clicked on a message box? my code is as shown below:
MessageBox.Show("Applicant already has interview date. Do you want to overwrite this date?", "Set interview", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (DialogResult.Yes)
{
sql = "insert into interview(FileLoc, date, time) values('" + id + "', '" + intdate.Text.ToString() + "', '" + inttime.Text.ToString() + "')";
cmd.ExecuteNonQuery();
}
推荐答案
捕获Show方法的返回值并针对DialogResult枚举进行测试
Capture the return value from the Show method and test against the DialogResult enum
DialogResult result = MessageBox.Show("Applicant already has interview date. Do you want to overwrite this date?", "Set interview", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if(result == DialogResult.Yes)
{
}
这篇关于我如何检查是否在消息框中单击了是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文