how to display a message box if an button action was successful in C# code example
Example 1: winforms messagebox with button
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
}
Example 2: how to do a messagebox in c#
MessageBox.Show("Content", "Title", MessageBoxIcon.Error)