操作类
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); } } }
时间的步伐有三种:未来姗姗来迟,现在像箭一样飞逝,过去永远静立不动.务请珍惜