Hi,
I've created a simple user control (uc_ok_cancel_apply) that includes OK, Cancel and Apply buttons. I want to use this on various user controls or forms so I can provide a consistent look.
If I add this to a user control, I can call a public method by referencing the form via the 'my' namespace
where uc_user1 is the name of the user control in which uc_ok_cancel_apply is contained.
However, I want the uc_ok_cancel_apply to call a public function on its parent control without having to resort to hard coding the reference. I thought I could use the 'parent' property eg. me.parent.parent.OK_clicked(), but I don't seem to be able to view the public sub.
Can anyone tell me how I can call a sub in the control that contains my user control? Do I need to use delegates and raiseevents? I've tried this but still don't seem to be able to get it work.
Thanks
I've created a simple user control (uc_ok_cancel_apply) that includes OK, Cancel and Apply buttons. I want to use this on various user controls or forms so I can provide a consistent look.
If I add this to a user control, I can call a public method by referencing the form via the 'my' namespace
VB.NET:
Private Sub btn_OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_OK.Click
'call the handling sub directly
My.Forms.frm_home.Uc_user1.OK_clicked()
End Sub
where uc_user1 is the name of the user control in which uc_ok_cancel_apply is contained.
However, I want the uc_ok_cancel_apply to call a public function on its parent control without having to resort to hard coding the reference. I thought I could use the 'parent' property eg. me.parent.parent.OK_clicked(), but I don't seem to be able to view the public sub.
Can anyone tell me how I can call a sub in the control that contains my user control? Do I need to use delegates and raiseevents? I've tried this but still don't seem to be able to get it work.
Thanks