zoukankan      html  css  js  c++  java
  • 关于窗口的关闭的问题

    转载  关于窗口的关闭的问题 收藏

    private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {
       // Determine if text has changed in the textbox by comparing to original text.
       if (textBox1.Text != strMyOriginalText)
       {
          // Display a MsgBox asking the user to save changes or abort.
          if(MessageBox.Show("Do you want to save changes to your text?", "My Application",
             MessageBoxButtons.YesNo) ==  DialogResult.Yes)
          {
             // Cancel the Closing event from closing the form.
             e.Cancel = true;
             // Call method to save file...
          }
       }
    }

    在此Form的Closing事件中写:
    private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {
    DialogResult dr=MessageBox.Show("你确实要退出?","提示",
    MessageBoxButtons.YesNo,MessageBoxIcon.Information);
    if(dr==DialogResult.Yes)
     Application.Exit();
    else
     e.Cancel=true;
    }
    如果点击Yes则退出,点击No则取消。

  • 相关阅读:
    图像处理笔记(五)
    图像处理笔记(四)
    图像处理(三)
    图像处理(二)
    图像处理(一)
    Halcon安装注意事项
    Tensorflow从开始到放弃(技术篇)
    Tensorflow从开始到放弃
    python 2.x中的中文
    WPF使用border画框
  • 原文地址:https://www.cnblogs.com/chenqingwei/p/1765253.html
Copyright © 2011-2022 走看看