I am assigning a click event handler like so
var buttonEvent = button.GetType().GetEvent("Click");
var eventMethod = GetType().GetMethod("button_Click");
var handler = Delegate.CreateDelegate(buttonEvent.EventHandlerType, this, eventMethod);
buttonEvent.AddEventHandler(button, handler);
The click event handler is like so:
void button_Click(object sender, EventArgs e) { }
How can I pass custom args into the handler? Ideally I would love
void button_Click(object sender, MyCustomEventArgs e) { }
where I can set MyCustomEventArgs when I assign the event.
Aucun commentaire:
Enregistrer un commentaire