Based on additional comments below the question, the real goal is to raise an event via reflection.
I'll start by saying this is almost guaranteed to be a really terrible idea. It's going to be error-prone and brittle; it's just asking for bugs. What I'd recommend instead is having many event handlers (button click handler, keypress event handler, etc.) all simply call a common method which does the actual thing you want.
That having been said, here's how to do it. Reflection is always brittle, and this is a prime example of it - you have to rely on the current implementation details of how events in .NET work, which could change tomorrow, and this will stop working. You get a private field stored on the object which holds references to all the subscribing event handlers, loop through each one and invoke it. You also need to manually create the arguments that will be passed (like the EventArgs):
var eventArgs = EventArgs.Empty; //replace with real args
var eventInfo = tExForm.GetType().GetEvent("Click", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
var eventDelegate = (MulticastDelegate)tExForm.GetType().GetField("Click", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(tExForm);
if (eventDelegate != null)
{
foreach (var handler in eventDelegate.GetInvocationList())
{
handler.Method.Invoke(handler.Target, new object[] { tExForm, eventArgs });
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…