One of the interesting features of C# is the ability to add custom user controls to your forms. If you have some specific functionality centered around a group of form controls that you use repeatedly, you can save it as a custom control in a class library and then add it to other applications. This is a great example of code reuse and saves a lot of time.
I’m starting to get the hang of creating demo videos with Camtasia and other tools and my latest videos show how to create user controls and implement them within Visual Studio.
Very often, you’ll want your custom controls to communicate with the host application, passing data back and forth and one way to do this is to have your control raise custom events at specific times. The host application listens for these events and responds as it needs to. This is a very powerful ability that enables your classes to interact in more dynamic ways. Once you understand how to raise and catch custom events, you’re no longer dependent on the C# event model and your applications can signal and respond to any condition you want them to.
The second video builds on the first part to show how to add custom events to your classes.
I encourage you to follow along with the videos and try creating the controls yourself. Also, experiment with your own ideas so that you’ll better understand the concepts.
If you would like to read more about creating custom events in C#, you can find more detail on the Microsoft website at the following links:
How to Raise and Consume Events
Handling and Raising Events