queryapplicationcontext.cs
来自「Microsoft?Visual C#?.NET (Core Reference」· CS 代码 · 共 36 行
CS
36 行
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace AppContext
{
public class QueryApplicationContext: ApplicationContext
{
private string _saveMessage = "Exit and discard changes?";
private string _caption = "Application Exit";
public QueryApplicationContext(MainForm form)
{
form.Show();
form.Closing += new CancelEventHandler(FormClosing);
}
private void FormClosing(object sender, CancelEventArgs e)
{
DialogResult result = MessageBox.Show(_saveMessage,
_caption,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1);
if(result == DialogResult.Yes)
{
ExitThread();
}
else
{
e.Cancel = true;
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?