As a follow up to: access values within custom eventargs class
How do I access public variables within custom Eventargs class, using button click or any other method?
When the button click event is raised, it's creating the EventArgs
that gets passed into "e". That object was not created by you, but rather by the framework itself, and is of type EventArgs
. This prevents you from being able to cast it to a different type.
If you want to have an event that raises TraderEventArgs
, you need to create an event, preferably of type EventHandler
, and raise this event somewhere that is in your control. This allows you to generate the class of the correct type, then handle it (in a separate event handler) directly.