using System; using System.Windows.Forms; using System.Drawing; class ex : Form { Button b1 = new Button(); ex() { Text = "hello"; b1.Text = "example"; b1.Click += new EventHandler(button_b1_click); Controls.Add(b1); } void button_b1_click(object sender, EventArgs e) { MessageBox.Show("example message"); } static public void Main() { Application.Run(new ex()); } }