Comeau Software Solutions

Making sense of technology since 2000.

Menu
  • Home / Updates
  • Services / Contact Us
  • Rogue C# Project Page
  • More Resources
    • Join Ocala’s Tech Community!
    • YouTube Channel
    • Personal Site
Menu

Custom User Controls and Events in C#

Posted on October 22, 2018 by Andrew Comeau

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.

Part 1:

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
https://docs.microsoft.com/en-us/dotnet/standard/events/how-to-raise-and-consume-events

Handling and Raising Events
https://docs.microsoft.com/en-us/dotnet/standard/events/index

 


Available on Amazon.com


Logitech Mouse / Keyboard dongle
Logitech Unifying Receiver for Mouse and Keyboard
Connects up to 6 Devices with any Logitech products that display the Unifying logo

Logitech

ComeauSoftware.com provides learning resources, including tutorials and videos, to help you in understanding today's technology. Please check out our YouTube channel and bookmark this site to stay informed of upcoming projects.

Comeau Software Solutions also provides software consultation, including the development of data solutions, in Ocala, Florida. This includes help with Microsoft Access database projects and assistance in moving to other solutions when needed. Please contact us for more information on how we can help you with your project needs.

Available on Amazon.com


Stanley Quencher H2.0 FlowState Stainless Steel Vacuum Insulated Tumbler
Keep your drinks hot or cold for hours! Stay cool at the beach or enjoy your coffee on the go with this 40 oz. insulated drink tumbler. BPA free and dishwasher safe.

Stanley
  • Articles
  • C#
  • Careers
  • Commentary
  • Database Design
  • Databases
  • Hardware
  • How-to
  • Humor
  • Internet
  • Jobs
  • Linux
  • Microsoft Access
  • MySQL
  • Ocala I.T. Professionals
  • Personal
  • Personal Tech
  • Programming
  • Resources
  • Reviews
  • Rogue C# Series
  • Software
  • SQL
  • Uncategorized
  • Web Design
  • Writing
©2023 Comeau Software Solutions | Theme by SuperbThemes