c#Winform 关闭前提示是否关闭程序

        private void SubForm1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (end_ser)
            {
                MessageBox.Show("未关闭串口!");
                e.Cancel = true;//关键语句
             }
        }

参考
Winform 关闭前提示是否关闭程序

发布了30 篇原创文章 · 获赞 3 · 访问量 909

猜你喜欢

转载自blog.csdn.net/qq_42697866/article/details/102807763