|
-
March 11th, 2010, 09:59 AM
#1
MessageBox in C#
Hi
I am a C++ programmer but am having to do a small app in C#
I want to display a Message Box so wrote
Code:
MessageBox.Show("The diagram already exists - Do you want to overrite?", "Diagram Exists",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
But the compiler says
C:\VSProjects\Addin2\Class1.cs(180,29): error CS0103: The name 'MessageBox' does not exist in the current context
How can I fix this?
Graham
-
March 11th, 2010, 10:18 AM
#2
Re: MessageBox in C#
Make sure System.Windows.Forms is referenced.
-
March 11th, 2010, 11:08 AM
#3
Re: MessageBox in C#
Btw SomersetBoy, in Visual Studio you can right click on Types that you know should be right, but aren't scopped, and go to Resolve->Include namespace. It will automatically add the namespace using for you, or explicitly scope the Type in question.
-
March 12th, 2010, 04:04 AM
#4
Re: MessageBox in C#
 Originally Posted by mariocatch
Btw SomersetBoy, in Visual Studio you can right click on Types that you know should be right, but aren't scopped, and go to Resolve->Include namespace. It will automatically add the namespace using for you, or explicitly scope the Type in question.
That's indeed a nice feature in VS, but will only work if the type is referenced.
-
March 15th, 2010, 03:04 AM
#5
Re: MessageBox in C#
Stress that assembly System.Windows.Forms.dll is meant, because the namespace name is the same, but you haven't access to the namespace until you reference the assembly.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
-
March 17th, 2010, 10:12 PM
#6
Re: MessageBox in C#
 Originally Posted by dannystommen
That's indeed a nice feature in VS, but will only work if the type is referenced.
Yep, but that's where Msdn comes into play:
MessageBox Class
Displays a message box that can contain text, buttons, and symbols that inform and instruct the user.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|