Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys
I have A Parent Windows Form , Form some Actions and an Event Occur in this Form an User Control Appear , in The Child User Control when a Button Ok is Pressed i want , To transfer Data To the Parent Windows Form , any one can help me in doing that
thanks to every one
Posted

If the button is in the user control, have it raise an event passing the data in the args that the form can hook in to.
Pass value between forms using events[^]
Events Made Simple[^]
 
Share this answer
 
1. Declare a custom EventArgs that can hold the information you wish to pass on from the UserControl to the Form.
2. Declare an Event in the UserControl that takes in the EventArgs declared above.
3. Make the Form subscribe to the event in the Form's Load event.
4. When raising the event from the UserControl, build a new instance of the custom EventArgs with the information you wish to pass and pass it along when you raise the event.
5. The form's method that handles the UserControl's event will get the custom EventArgs instance. Use it in your form.
 
Share this answer
 
Comments
Yasser El Shazly 27-Jul-11 5:24am    
can you send me some code for more explanation , thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900