Visual C# 2005 Recipes



A P P L I C AT I O N D E V E L O P M E N T
6
// Configure textBox1, which accepts the user input.
this.textBox1.Location = new System.Drawing.Point(152, 32);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";

// Configure button1, which the user clicks to enter a name.
this.button1.Location = new System.Drawing.Point(109, 80);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "Enter";
this.button1.Click += new System.EventHandler(this.button1_Click);

// Configure WelcomeForm, and add controls.
this.ClientSize = new System.Drawing.Size(292, 126);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Name = "form1";
this.Text = "Visual C# 2005 Recipes";

// Resume the layout logic of the form now that all controls are
// configured.
this.ResumeLayout(false);

}
// Event handler called when the user clicks the Enter button on the
// form.
private void button1_Click(object sender, System.EventArgs e)
{

// Write debug message to the console.
System.Console.WriteLine("User entered: " + textBox1.Text);

// Display welcome as a message box.
MessageBox.Show("Welcome to Visual C# 2005 Recipes, "

+ textBox1.Text, "Visual C# 2005 Recipes");
}
// Application entry point, creates an instance of the form, and begins
// running a standard message loop on the current thread. The message
// loop feeds the application with input from the user as events.
[STAThread]
public static void Main()
{

Application.EnableVisualStyles();
Application.Run(new Recipe01_02());

}
}
}
Usage
To build the Recipe01-02 class into an application, use this command:
csc /target:winexe Recipe01-02.cs.
The /target:winexe switch tells the compiler that you are building a Windows-based applica-
tion. As a result, the compiler builds the executable in such a way that no console is created when