开发者

Custom event in a winform usercontrol

I am adding a usercontrol dynamically to a winform. The user control has a custom event.

form_load()
{
ucUpdateProgress ucUP = new ucUpdateProgress();
ucUP.customEvent += new EventHa开发者_如何学运维ndler<CustomEventArgs>(ucUP_customEvent);
this.Controls.Add(new ucUpdateProgress());
}

I am calling this event when the user click the cancel button. But the customevent's value is null. Why is that? Whats wrong with my code?

private void button1_Click(object sender, EventArgs e)
    {
        CustomEventArgs cEA = new CustomEventArgs(true);
        customEvent(sender, cEA);
    }  

Thanks, Syd


That should be

this.Controls.Add(ucUP)

not

this.Controls.Add(new ucUpdateProgress());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜