Auto-generate event handler at runtime.