|
|
Events
Chap4_Ex24.cs
using System;
using System.Windows.Forms;
using System.Drawing;
public class ButtonForm : Form {
private System.Windows.Forms.Button Red;
private System.Windows.Forms.Button Green;
private System.Windows.Forms.Button Blue;
public ButtonForm() {
this.InitializeComponent();
}
private void InitializeComponent() {
this.Red = new System.Windows.Forms.Button();
this.Green = new System.Windows.Forms.Button();
this.Blue = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// Red
//
this.Red.Location = new System.Drawing.Point(24, 16);
this.Red.Name = "Red";
this.Red.TabIndex = 0;
this.Red.Text = "Red";
this.Red.Click += new System.EventHandler(this.Red_Click);
//
// Green
//
this.Green.Location = new System.Drawing.Point(24, 48);
this.Green.Name = "Green";
this.Green.TabIndex = 1;
this.Green.Text = "Green";
this.Green.Click += new System.EventHandler(this.Green_Click);
//
// Blue
//
this.Blue.Location = new System.Drawing.Point(24, 80);
this.Blue.Name = "Blue";
this.Blue.TabIndex = 2;
this.Blue.Text = "Blue";
this.Blue.Click += new System.EventHandler(this.Blue_Click);
//
// ButtonForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(120, 133);
this.Controls.Add(this.Blue);
this.Controls.Add(this.Green);
this.Controls.Add(this.Red);
this.Name = "ButtonForm";
this.ResumeLayout(false);
}
private void Red_Click(object sender, System.EventArgs e) {
this.BackColor = Color.Red;
}
private void Green_Click(object sender, System.EventArgs e) {
this.BackColor = Color.Green;
}
private void Blue_Click(object sender, System.EventArgs e) {
this.BackColor = Color.Blue;
}
}
public class Chap4_Ex24_Test {
public static void Main(string[] args) {
Application.Run(new ButtonForm());
}
}
|
|