IntelliSense not showing MessageBoxResult

≯℡__Kan透↙ 提交于 2020-01-06 03:40:08

问题


I am working with a Windows Forms application in C# and Visual Studio 2005.

I am showing a message box within an button click event,

string messageBoxText = "Click OK to save your changes\n";
string caption = "Confirm Changes";
MessageBoxButtons button = MessageBoxButtons.OKCancel;
//Display the MessageBox
MessageBox.Show(messageBoxText, caption, button);

MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button);

The following error pops up on compilation:

Error 1 The type or namespace name 'MessageBoxResult' could not be found (are you missing a using directive or an assembly reference?)

Also, IntelliSense does not show any such thing as MessageBoxResult. I have seen this statement on MSDN. How to capture the response of the message (OK/Cancel) without using MessageBoxResult?


回答1:


The MessageBoxResult Enumeration is only available on .NET 3.0+. You're using 2.0.

Use DialogResult as Walt suggested.




回答2:


You could try placing

using System.Windows; 

at the top of your source.

Or try DialogResult instead. That's in the System.Windows.Forms namespace, and is what Show() returns in my C# source files...



来源:https://stackoverflow.com/questions/1330378/intellisense-not-showing-messageboxresult

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!