I have MessageBox only with Ok
button, although there's close button. But in code I can check only DialogResult.Ok
.
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?
Asked
Active
Viewed 5,477 times
0

Jim
- 2,974
- 2
- 19
- 29

Aleksandr Storozhuk
- 15
- 1
- 4
1 Answers
5
You can do this way,
DialogResult result = MessageBox.Show("Message", "Tests", MessageBoxButtons.OKCancel);
if (result == DialogResult.OK)
{
}
else if (result == DialogResult.Cancel)
{
}

Jules
- 567
- 1
- 6
- 15

Sajeetharan
- 216,225
- 63
- 350
- 396