Delegates

using System;
using System.Windows.Forms;

class Click {

    static void Action (object sender, EventArgs arg) {
        Console.WriteLine ("clicked");
    }

    static void Main () {
        Form f = new Form ();

        // leider noch nicht in Mono
        // Panel p = new System.Windows.Forms.FlowLayoutPanel ();
        // f.Controls.Add (p);

        Button b = new Button ();
        b.Text = "foo";
        b.Click += Click.Action;
        f.Controls.Add(b);

        Application.Run (f);
    }
}



Johannes Waldmann 2006-06-22