Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MessageBox close another form

Tags:

c#

Hello Guys I have msg box when i press on yes its close that form which calls msg box how can i do when msg box dialogresult = ok close only himself

like image 335
Irakli Lekishvili Avatar asked Nov 17 '10 18:11

Irakli Lekishvili


2 Answers

Set the DialogResault property to None for the button which its event handler open the MessageBox.

Good luck!

like image 82
Homam Avatar answered Nov 13 '22 13:11

Homam


DialogResult result = MessageBox.Show("Click yes to close, otherwise click no.", "Message Box Test", MessageBoxButtons.YesNo);

if (result == DialogResult.Yes)
{
  Application.Exit();
}
like image 1
JohnB Avatar answered Nov 13 '22 12:11

JohnB