O'Reilly logo

.NET Framework 4.5 Expert Programming Cookbook by A.P. Rajshekhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating an event that can have generic values as payload

In a Windows Forms Application project, you can make communication happen among forms by using events. To raise custom events, you can make use of EventHandler delegates with EventArgs as argument. However, built-in EventArgs does not allow you to pass data as payload. So, by default, if you want to pass data among the forms, you will have to make use of both events (to indicate that the data has changed) and properties (to access the changed data). But there is another way – to extend EventArgs and add the capability to accept payloads. This recipe will tell you how to do it.

During the process of implementing the custom EventArgs by extending EventArgs, one point to keep in mind is that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required