用户控件回发事件到主窗口的方法
时间:2011-02-28 来源:ㄨУΘSeven
public partial class TestUC : UserControl
{
public event UCHandler UCEvent;
private void btnTest_Click(object sender, EventArgs e)
{
UCEvent arg = new UCEvent();
arg.str = "12345";
this.UCEvent(this, arg);
}
}
主窗口加入代码
private void Event(object sender, UCEvent e)
{
label1.Text=e.str;
}
private void frmMainWindow_Load(object sender, EventArgs e)
{
TestUC uc=new TestUC();
uc.UCEvent += new UCHandler(Event);
panelMain.Controls.Add(uc);
}
相关阅读 更多 +