我创建一个事件并在表单上处理它
用户控制代码:
public event EventHandler ButtonClick;
private void button1_Click(object sender, EventArgs e)
{
if (this.ButtonClick != null)
this.ButtonClick(sender, e);
}
表格代码:
private Usercontrol1 sampleUserControl = new Usercontrol1();
public Form1()
{
InitializeComponent();
sampleUserControl.ButtonClick += new EventHandler(this.UserControl_ButtonClick);
}
private void UserControl_ButtonClick(object sender, EventArgs e)
{
//sample event stuff
this.Close();
Form2 F2 = new Form2();
F2.Show();
}
但事件没有触发。一定是什么问题?