using System; using System.Drawing; using System.Windows.Forms; public class notepad : Form { Button ok = new Button(); TextBox text = new TextBox(); static public void Main () { Application.Run (new notepad ()); } public notepad() { this.Size = new Size(400,200); this.StartPosition = FormStartPosition.CenterScreen; ok.Size = new Size(64,64); ok.Location = new Point(10,10); ok.Click += new EventHandler(ok_click); ok.Text = "OK"; this.Controls.Add(ok); text.Size = new Size(164,64); text.Location = new Point(100,10); text.Font = new Font(text.Font.FontFamily,24); this.Controls.Add(text); } private void ok_click(object sender, EventArgs e) { if (text.Text == "9999") { MessageBox.Show("TOP SECRET"); } } }
Przykładowy program napisany w mono pokazujący jak stworzyć obsługę zdarzeń dla przycisku