我有一些用于MessageBox的代码,但在使用System.Windows.Forms!?时,在代码下面和类的开头出现了一条红线。
添加使用System.Windows.Forms来显示MessageBoxes还不够吗?或者我可能遗漏了其他东西?提示是精准的!谢谢!
编辑:
错误消息: error 1类型或命名空间名称'Windows‘在命名空间'System’中不存在(是否缺少程序集引用?)
发布于 2012-07-31 20:44:31
您应该添加一个对System.Windows.Forms
的引用
你可以这样做:
System.Windows.Forms
,然后按OK (或双击)发布于 2012-07-31 20:46:50
System.Windows.MessageBox和System.Windows.Forms.MessageBox之间可能存在歧义
因此,为了简单起见,可以将其声明为System.Windows.MessageBox.Show()
发布于 2012-07-31 20:45:15
试试这篇文章
http://msdn.microsoft.com/fr-fr/library/system.windows.forms.messagebox.aspx
const string message =
"message";
const string caption = "your test";
var result = MessageBox.Show(message, caption,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
// If the no button was pressed ...
if (result == DialogResult.No)
{
// cancel the closure of the form.
e.Cancel = true;
}
https://stackoverflow.com/questions/11740331
复制相似问题