开发者

UserControl event

I created a usercontrol, it consists of a picturebox with an image, add开发者_开发知识库 it to project, try to expose him to a click event, but it does not respond! What am I doing wrong? http://www.fileserve.com/file/yk9sjAu - usercontrol http://www.fileserve.com/file/4353g9z - my project


The click event only fires for clicks directly on your UserControl itself - not it's children.

To pass clicks from these as well, you need to chain the events:

    public UserControl1()
    {
        InitializeComponent();

        this.pictureBox1.Click += (s,e) => {base.OnClick(e);};
        this.checkBox1.Click += (s,e) => {base.OnClick(e);};
    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜