Aleksandr Storozhuk Aleksandr Storozhuk - 7 months ago 63
C# Question

MessageBox closed event

I have MessageBox only with

button, although there's close button. But in code I can check only
How should I check which button user had pressed?
Only as
if (MessageBox("error") != DialogResult.Ok)
or there's another way?
Is any event, that occures, when user closes MessageBox?


You can do this way,

 DialogResult result = MessageBox.Show("Message", "Tests", MessageBoxButtons.OKCancel);
 if (result == DialogResult.OK)

 else if (result == DialogResult.Cancel)