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);};
}
精彩评论