//p332
using System;
using System.Windows.Forms;
using System.Drawing;
//descends from the From class
public class WindowWithButton : Form
{
Button button1 = new Button(); //Button object named button1
public WindowWithButton() //constructor
{
this.Size = new System.Drawing.Size(300, 300);
//Size field for the Form
this.Text = "Window Object With Button";
//Text field for the Form
button1.Text = "Press"; //Text field for the Button
this.Controls.AddRange(new System.Windows.Forms.Control[] { this.button1 });
/*
Controls.AddRange() method to indicate that the Button
you created will become one of the Form's usable controls.
*/
this.button1.Location = new System.Drawing.Point(100, 50);
//locate the Button at position 100, 50 on the Form
}
//Main() method to execuate the application
public static void Main()
{
Application.Run(new WindowWithButton());
}
}