操作类

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{

    public partial class Form1 : Form
    {
        Customer c;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
             c = new Customer();
            c.OnChange += new EventHandler(c_OnChange);
           
        }

        void c_OnChange(object sender, EventArgs e)
        {
            MessageBox.Show("事件触发!");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            c.Change();
        }
    }
}
using System;
using System.Collections.Generic;
using System.Text;

namespace WindowsFormsApplication1
{
    class Customer
    {
        public event EventHandler OnChange;
        public void Change()
        {
            if (OnChange != null)
                OnChange(this, null);
        } 
    }
}

posted on 2013-10-22 17:00  Asa.Zhu  阅读(170)  评论(0编辑  收藏  举报