【发布时间】:2013-11-26 22:47:18
【问题描述】:
如何在删除记录前显示确认消息框?按钮只能是 YES 或 NO。不是OK 或CANCEL。我有这段代码,但它只适用于 c# winforms...
if (MessageBox.Show("Delete record no. " + numID.Text + "?", "Confirm User Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
//codes to delete records
}
【问题讨论】:
-
您需要添加对 System.Windows.Forms 库的引用,并且您必须在程序中引用它,例如 -> using System.Windows.Forms;声明。
-
取决于您使用的技术,一个好的建议是使用 Javascript 的确认功能。请将其嵌入到您的代码中,让用户决定,然后继续您的操作。有一个similar question about it here。 Here is some more light。 And a good example in this link。希望对你有帮助,
-
我收到此错误
The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?) -
您不想使用 Windows.Forms.MessageBox。别傻了。
-
没有是/否选项