User control question

  • Thread starter Thread starter Bobby Edward
  • Start date Start date
B

Bobby Edward

In my data "admin" pages I often have functions which I want to confirm.

I created a generic user control called ucActions. It has 3 buttons:
Action, Confirm and Cancel

Confirm and Cancel only are visible when the Action button is pressed. The
generic Action button might be "Delete", for example.

Since this uc is dealing with generic actions I wanted the main action code
to be in the form that references the user control, not the uc itself.

How can I do this? I would like the parent form to "know" which button was
pressed - Confirm or Cancel - then act accordingly.
 
FYI: I think I got it working using events and delegates...

In my uc I did this...
Public Delegate Sub OnConfirmClick()

Public Event ConfirmClickHandler As OnConfirmClick

Protected Sub cmdConfirm_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdConfirm.Click

RaiseEvent ConfirmClickHandler()

End Sub


Then, in the parent form I just wrote code for...
Protected Sub ucActionConfirm1_ConfirmClick() Handles
ucActionConfirm1.ConfirmClickHandler


That's it! I hope this is helpful to someone else!
 
Back
Top