Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a simple popup box in Visual C#?

When I click a button, I want a box to popup on the screen and display a simple message. Nothing fancy really. How would I do that?

like image 417
neuromancer Avatar asked Nov 27 '09 00:11

neuromancer


People also ask

How do I create a popup box in Visual Studio?

Just type mbox then hit tab it will give you a magic shortcut to pump up a message box. Note: This only works in Visual Studio.

How do you pop up a form in C#?

To add an alert window to the Form, create a handler for the Button Click event by simply double clicking on the button. Now, copy and paste the following C# code snippet to the button click event handler. This code creates a PopupNotifier, sets its title and text and openss the popup.

How do I add a pop up box?

Select Edit Website to open your website editor. Select the Website tab at the top of your editor then select Popup from Website Add-Ons. Customize your pop-up box. Enable Pop-up: Toggle this feature to turn your pop-up box on and off.


3 Answers

System.Windows.Forms.MessageBox.Show("My message here"); 

Make sure the System.Windows.Forms assembly is referenced your project.

like image 121
Alex J Avatar answered Sep 28 '22 10:09

Alex J


Just type mbox then hit tab it will give you a magic shortcut to pump up a message box.

like image 22
Spence Avatar answered Sep 28 '22 09:09

Spence


Try this:

string text = "My text that I want to display";
MessageBox.Show(text);
like image 22
user6436606 Avatar answered Sep 28 '22 10:09

user6436606