Exit application : Introduction « GUI Windows Forms « C# / CSharp Tutorial






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(); 
  } 
}








23.1.Introduction
23.1.1.Empty FormEmpty Form
23.1.2.First Window ApplicationFirst Window Application
23.1.3.A form-based Windows Skeleton
23.1.4.Exit application
23.1.5.Button click handlerButton click handler
23.1.6.Use Application.Run to load window application
23.1.7.Subclass Form to create a window
23.1.8.Essential elements of a Windows Forms application.