Click here to Skip to main content
15,886,019 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I'm trying to create something similar to MessageBox.Show(), where I have to press the button okay or close the MessageBox to continue. Not a good explainer but this will get you the idea.

int a = 0;
MessageBox.Show("int a ( will set to 1 after pressin/closing the MessageBox)");
a = 1;


What I have tried:

Couldn't find anything to try.
Posted
Updated 16-Mar-18 1:23am

Try:
C#
MyFormToDisplay form = new MyFormTopDisplay();
form.Message = "Hello - this will not continue until you close me";
if (form.ShowDialog() == DialogResult.OK)
   {
   // OK pressed
   ...
   }
 
Share this answer
 
Thanks this would solve it, But I'm also curious about how you made a stop in
if (form.ShowDialog() == DialogResult.OK)
Like similar to the Console.ReadLine() in a ConsoleApplication, I have a feeling this would help me alot later

EDIT: this worked in WPF on a new project, but when I include System.Windows.Forms in my main one, I get this error
CS0176	Member 'HorizontalAlignment.Left' cannot be accessed with an instance reference; qualify it with a type name instead
Is there an other way of doing this?
 
Share this answer
 
v3
Comments
Richard Deeming 16-Mar-18 12:55pm    
If you want to reply to a solution, click the "Have a Question or Comment?" button under that solution.

DO NOT post your comment as a new "solution".

And most definitely DO NOT mark your comment as "the answer" to your question!
Thaana Paana 16-Mar-18 22:26pm    
oo, my bad. Still pretty new to the site xd

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900