User control question

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.
 
B

Bobby Edward

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top