退出应用程序 [英] exit the apllication

查看:88
本文介绍了退出应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想使用代码隐藏代码退出应用程序。

任何人都可以告诉我。

我不想要自己来自javascript的.close()或window.close()方法。

此外,如果我直接从浏览器关闭应用程序(单击关闭浏览器的关闭按钮),那么是否可以提供消息?

提前感谢。

解决方案

  public   static   void  Main( string  [] args){
// 启动应用程序。
Application.Run( new Form1中());
}

private void button1_Click( object sender,System.EventArgs e){
// 填充a带有三个数字的列表框。
int i = 3 ;
for int j = 1 ; j< = i; j ++){
listBox1.Items.Add(j);
}

/ * 确定用户是否要退出应用程序。
*如果没有,请在列表框中添加另一个数字。 * /

while (MessageBox.Show( 退出应用程序? ,MessageBoxButtons.YesNo)= =
DialogResult.No){
// 递增计数器并将数字添加到列表中框。
i ++;
listBox1.Items.Add(i);
}

// 用户想要退出应用程序。关闭所有内容。
Application.Exit();
}









或尝试以下链接



http:// stackoverflow。 com / questions / 3201770 / exit-code-from-windows-forms-app [ ^ ]


Save&退出Web应用程序 [ ^ ]

Hi,
I want to exit the application using codebehind code.
Can any body please tell me.
I dont want self.close() or window.close() method from javascript.
Also if i am closing the application directly from browser (means on clicking close button of browser) so is it possible to give message?
thanks in advance.

解决方案

public static void Main(string[] args) {
    // Starts the application.
    Application.Run(new Form1());
 }

 private void button1_Click(object sender, System.EventArgs e) {
    // Populates a list box with three numbers.
    int i = 3;
    for(int j=1; j<=i; j++) {
       listBox1.Items.Add(j);
    }

    /* Determines whether the user wants to exit the application.
     * If not, adds another number to the list box. */
    while (MessageBox.Show("Exit application?", "", MessageBoxButtons.YesNo) ==
       DialogResult.No) {
       // Increments the counter ands add the number to the list box.
       i++;
       listBox1.Items.Add(i);
    }

    // The user wants to exit the application. Close everything down.
    Application.Exit();
 }





or try below link

http://stackoverflow.com/questions/3201770/exit-code-from-windows-forms-app[^]


Save & Exit in Web Application[^]


这篇关于退出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆