亨利.王

如何自定义事件

如何定义事件:

1、定义一个事件参数  继承与 EventArgs:

pulic class ActionEventArgs : EventArgs{}

2、定义一个事件委托: public delegate void ActionEventHanlder(object sender, ActionEventArgs e);

3、定义事件: public event ActionEventHanlder showProecc;

4、定义处理函数: pulic void Test(object sender, ActionEventArgs e){}

5、注册事件: showProecc+= new ActionEventHanlder(Test);

6、调用

Application.DoEvents(); --异步执行显示

ActionEventArgs arg=new ActionEventArgs();

showProecc(sendar,arg);

posted on 2011-08-15 13:22  亨利.王  阅读(370)  评论(0编辑  收藏  举报

导航