Real World Usage:
- Assume you have a simple user control called Checker- which comprises of just 2 checkboxes - chkA and chkB.
- Within the user-control you can control the check/uncheck events by implementing the respective events fro chkA and ChkB
3.Now, in a new Win Form , when you drag in Checker...and your objective is to make sure that when chkA is clicked you have to change the background color of a label...lblColorPicker.
Mind you lblColorPicker is a control that exists in the form and is not directly bound to Checker.
How will you achieve this?
Answer:
- First, you have to create a new event for your user control Checker.
- To create this new event the first thing would be to create a delegate in you user control and then use this delegate as a defining type for the new event you are writing.
- And then this Event has to be mapped to chkA...event in your user control.
This way you can control chkA...through the new event from any new form by referencing the event...through a delegate you just wrote.
So, much for Real-World usage!
This objective CANNOT be achieved with out writing the delegate.
Let me know if you think otherwise...or if you need more elaboration.