UserControl _Click Event
-
Hi all, I've created a UserControl having a picturebox control on it. Then I added my UserControl to the Windows Form and also added the _Click event. My problem is; when I click the UserControl the event is fired just fine but when I click the picturebox on the UserControl - nothing happens. What would you suggest? :doh: Thanks Radgar
-
Hi all, I've created a UserControl having a picturebox control on it. Then I added my UserControl to the Windows Form and also added the _Click event. My problem is; when I click the UserControl the event is fired just fine but when I click the picturebox on the UserControl - nothing happens. What would you suggest? :doh: Thanks Radgar
Add an event handler to your UserControl that catches the Click event of the contained PictureBox and raises the Click event of your UserControl.
YourUserControl : UserControl
{
private PictureBox pictureBox1;
...
this.pictureBox1.Click += new EventHandler(pictureBox1_Click);
...
private void pictureBox1_Click(object sender, EventArgs e)
{
this.OnClick(e);
}
}
-
Add an event handler to your UserControl that catches the Click event of the contained PictureBox and raises the Click event of your UserControl.
YourUserControl : UserControl
{
private PictureBox pictureBox1;
...
this.pictureBox1.Click += new EventHandler(pictureBox1_Click);
...
private void pictureBox1_Click(object sender, EventArgs e)
{
this.OnClick(e);
}
}