Home

Published

- 1 min read

winforms messagebox with button

img of winforms messagebox with button

The solution for this is noted below

winforms messagebox with button

Solution

   string message = "Do you want to close this window?";  
string title = "Close Window";  
MessageBoxButtons buttons = MessageBoxButtons.YesNo;  
DialogResult result = MessageBox.Show(message, title, buttons);  
if (result == DialogResult.Yes) {  
    this.Close();  
} else {  
    // Do something  
}

Try other methods by searching on the site. That is if this doesn’t work