本文介绍了记事本应用程序关闭按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在记事本示例中,单击关闭"按钮,询问您是否要保存,不保存,不保存,取消options.how编写代码以显示这三个选项.

in Notepad example click to closeing button asked to do you want to save or not diasplay save,dontsave,cancel options.how to write code for displaying this three options

推荐答案


private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
    if (MessageBox.Show("Are you sure you want to close the application?",
        "Close?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
    {
        e.Cancel = true;
    }
}



现在,您只需开发一个具有三个按钮的新表单,即可返回DialogResult.YesDialogResult.NoDialogResult.Cancel.

将上面的代码中的MessageBox.Show替换为调用您的自定义窗口的代码.



Now you only have to develop a new form with three buttons, that returns a DialogResult.Yes, DialogResult.No and a DialogResult.Cancel.

Replace the MessageBox.Show in the above code with code that calls your custom window.


这篇关于记事本应用程序关闭按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 08:15