using System; using System.Windows; using System.Windows.Forms; namespace FormDemo { class Program { static void Main() { MyForm MainForm = new MyForm("Main Waindow"); MainForm.ShowDialog(); } } class MyForm : Form { private Button NewButton; private TextBox Output; public MyForm(string FormName) { Form NewForm = new Form(); this.Text= FormName; this.Output=new TextBox(); this.NewButton = new Button(); this.Controls.Add(this.NewButton); this.Controls.Add(this.Output); this.NewButton.Text = "ShowHello"; this.NewButton.Top = 20; this.NewButton.Click += ButtonClicked; } private void ButtonClicked(object sender, EventArgs e) { this.Output.Text = "Hello World"; } } }