Using a messagebox

H

Hans Kamp

How do I use an MsgBox in C#Builder?

The following code:

private void button1_Click(object sender, System.EventArgs e)
{
MsgBox("Blablabla");
}

causes the message (translated from Dutch):

[C# Error] WinForm.cs(89): The name MsgBox doesn't exist in the class or
namespace ShowName.WinForm

How do I correct the code? After clicking on the button button1, I want to
see a message box with the text "Blablabla".
Why is the error message in Dutch (I have Windows XP Home in Dutch)?

Hans Kamp.
 
K

Kevin McNeish [C# MVP]

Hans,
private void button1_Click(object sender, System.EventArgs e)
{
MsgBox("Blablabla");
}

causes the message (translated from Dutch):

[C# Error] WinForm.cs(89): The name MsgBox doesn't exist in the class or
namespace ShowName.WinForm

You need to use the Show() method of the MessageBox class rather than
calling a MsgBox function. For example:

MessageBox.Show("Here is my message", "This is the title");

Regards,
Kevin McNeish
C# MVP
Chief Software Architect, Mere Mortals .NET Framework
www.oakleafsd.com
 
H

Hans Kamp

Kevin McNeish said:
Hans,
private void button1_Click(object sender, System.EventArgs e)
{
MsgBox("Blablabla");
}

causes the message (translated from Dutch):

[C# Error] WinForm.cs(89): The name MsgBox doesn't exist in the class or
namespace ShowName.WinForm

You need to use the Show() method of the MessageBox class rather than
calling a MsgBox function. For example:

MessageBox.Show("Here is my message", "This is the title");

Aha! Thanks!

Hans Kamp.
 
S

Sean

System.Window.Forms.MessageBox.Show("BLAH");
[or]
If you are using the Form Code Page just: MessageBox.Show("BLAH");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top