110,571
社区成员
发帖
与我相关
我的任务
分享
class Program
{
static void Main(string[] args)
{
Button btn = new Button();
Delegate del = Delegate.CreateDelegate(typeof(EventHandler), typeof(Program).GetMethod("btn_Click", BindingFlags.Static | BindingFlags.NonPublic));
btn.Click += del as EventHandler;
btn.Text = "Test";
Form f = new Form();
f.Controls.Add(btn);
f.ShowDialog();
Console.ReadLine();
}
static void btn_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello");
}