C# - Use form instead of messagebox

Jake Sankey picture Jake Sankey · Mar 1, 2010 · Viewed 13.1k times · Source

I am working on an application for work and I need a customized messagebox to appear. I have created a simple form called Alert.cs that I have styled the way I want and added one button with a click method of this.Close(). now I want it to behave exactly like a standard messagebox.show(). I have the form showing but when I use the standard messagebox.show("text of alert") it waits to continue operation until the user click 'OK', this is what I want the form to do.

Answer

Kyle Rosendo picture Kyle Rosendo · Mar 1, 2010

Use Form.ShowDialog();. This allows the form to act the same way as a MessageBox in the sense that it retains focus until closed.