//3、根据委托(delegate)的知识,请完成以下用户控件中代码片段的填写:(10)
namespace test
{
public delegate void OnDBOperate(); public class UserControlBase : System.Windows.Forms.UserControl
{ public event OnDBOperate OnNew;
private void toolBar_ButtonClick(object sender,System.Windows.Forms.ToolBarButtonClickEventArgs e)
{ if(e.Button.Equals(BtnNew)) {
//请在以下补齐代码用来调用OnDBOperate委托签名的OnNew事件。 } } } 答:if( OnNew != null )
OnNew( this, e );
上网查询了一下,基本所有的答案都是
答:if( OnNew != null )
OnNew( this, e );
onnew哪有参数 this e啊 ?这么明显的错误,却那么多人转贴
查询了好多次之后我都开始怀疑自己的想法了,是不是我弄错了??
难道OnNew( this, e ); 真的可以编译通过??
public delegate void OnDBOperate(object sender,System.Windows.Forms.ToolBarButtonClickEventArgs e);