Visual Hello World in C#
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace lecture_09
{
///
/// Summary description for FormHW.
///
public class FormHW : System.Windows.Forms.Form
{
private System.Windows.Forms.Label labelHW;
private System.Windows.Forms.Button buttonClose;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public FormHW()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.labelHW = new System.Windows.Forms.Label();
this.buttonClose = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// labelHW
//
this.labelHW.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.labelHW.Location = new System.Drawing.Point(32, 64);
this.labelHW.Name = "labelHW";
this.labelHW.Size = new System.Drawing.Size(232, 64);
this.labelHW.TabIndex = 0;
this.labelHW.Text = "Hello World!";
//
// buttonClose
//
this.buttonClose.Location = new System.Drawing.Point(80, 168);
this.buttonClose.Name = "buttonClose";
this.buttonClose.Size = new System.Drawing.Size(128, 48);
this.buttonClose.TabIndex = 1;
this.buttonClose.Text = "Close";
this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
//
// FormHW
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.buttonClose);
this.Controls.Add(this.labelHW);
this.Name = "FormHW";
this.Text = "Hello World!";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new FormHW());
}
private void buttonClose_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}