Exemple #1
0
        static void Main(string[] args)
        {
            MyForm form = new MyForm();

            form.Click += form.FormClicked;
            form.ShowDialog();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            MyForm form = new MyForm();

            form.Click += form.FormAction;
            // ctrl + . 回车;自动在MyForm类里面,声明事件处理器.
            form.ShowDialog();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            //Event Sender and Event Subscriber
            MyForm form = new MyForm();

            form.Click += form.FormClicked;


            form.ShowDialog();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            //Form form = new Form();
            //form.Click += form.CustomHandler;

            // 1. 事件的拥有者(form)

            MyForm form = new MyForm();

            // 2. 事件 (Click)
            // 3. 事件的响应者(form)和事件拥有者是同一个对象
            // 5. 事件的订阅
            form.Click += form.CustomHandler;

            form.ShowDialog();
        }