Mega Code Archive

 
Categories / C# Tutorial / GUI Windows Forms
 

Exit application

using System;  using System.Windows.Forms;  using System.Drawing;    class FormExit : Form {    Button StopButton;      public FormExit() {      Text = "Adding a Stop Button";        StopButton = new Button();      StopButton.Text = "Stop";      StopButton.Location = new Point(100, 100);        StopButton.Click += StopButtonClick;      Controls.Add(StopButton);    }        [STAThread]    public static void Main() {      FormExit skel = new FormExit();        Application.Run(skel);    }      protected void StopButtonClick(object who, EventArgs e) {       Application.Exit();    }  }