Here is an example. You can try something like this.
var confirmResult = MessageBox.Show("Are you sure to delete this item ??",
"Confirm Delete!!",
MessageBoxButtons.YesNo);
if (confirmResult == DialogResult.Yes)
{
// If 'Yes', do something here.
}
else
{
// If 'No', do something here.
}
You can also try MessageBoxButtons.OKCancel
instead of MessageBoxButtons.YesNo
. It depends on your requirements.
- If you have .Net Framework 4.6 or above please try this.
MessageBoxResult confirmResult = MessageBox.Show("Are you sure to delete this item ??", "Confirm Delete!!", MessageBoxButton.YesNo);`
if (confirmResult == MessageBoxResult.Yes)
{
// If 'Yes', do something here.
}
else
{
// If 'No', do something here.
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…