delegates - Fire parent click event when child is clicked in windows form user control -


i have user control

    public partial class buttoncontrol : usercontrol 

which has 2 controls of label , picturebox

        this.picturebox1 = new system.windows.forms.picturebox();         this.text = new system.windows.forms.label(); 

i have used control in windows form

this.appointmentbutton = new dentalsoft.ui.controls.buttoncontrol(); 

created event

            this.appointmentbutton.click += new system.eventhandler(this.appointmentbutton_click); 

enter image description here

but problem is, if click on image or label inside of control, click event doesn't fire. want fire click event no matter user clicks inside of control. possible?

yes simple matter. when click on child controls receive click event , user control not. can subscribe child control click events , when occur raise usercontrol click event , appear click no matter mouse positioned.

just double click on picturebox , label create click event handlers add line of code call parent usercontrol onclick method.

    private void text_click(object sender, eventargs e)     {         this.onclick(new eventargs());     }      private void picturebox1_click(object sender, eventargs e)     {         this.onclick(new eventargs());     } 

Comments