This is the simplest approach (WinForms) to show a dialog box to ask for confirmation before deleting selected entities:
public class MyDesign : Design
{
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
if (MessageBox.Show("Do you want to delete the selected entities?", "Title", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
base.OnKeyDown(e);
}
}
}
}
Comments
Hi Alberto,
After adding this code, when i press the No button it still deletes the entity. We need to add an else case.
Regards
Z.Mustafa Cakir
I'm sorry. It's my mistake. Code works perfect.
Best regards
Z.Mustafa Cakir
Please sign in to leave a comment.