Winform 执行操作前确认MessageBox询问提示, 确认则执行, 取消则返回

Winform 执行操作前确认MessageBox询问提示, 确认则执行, 取消则返回
using System;
using System.Windows.Forms;

namespace WindowsFormsApp14
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("删除之后将不可恢复,确定删除吗?", "删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            else
            {
                MessageBox.Show("确认之后的事件");
            }
        }
    }
}


热门推荐