子窗体测试:
复制代码 if (this.SendTo != null) this.SendTo( "主窗体收到了吗? ");
【第四种方法:】
通过引用:
下例演示怎样通过引用类型实现你的功能:
子窗体中定义:
新构造函数:
?
- public ChildForm(MainForm parent) {
- InitializeComponent(); this.ParentFrom = parent;//引用
- }
主窗体中某Click:
?
- ChildForm frm = new ChildForm(this); frm.ShowDialog(this);
子窗体测试:
?
- void ...Click(....) {
- this.Text = "测试引用 "; if (this.ParentFrom != null) this.ParentFrom.Text += "- " + this.Text;//.......
- }
希望本文所述对大家的C#程序设计有所帮助。










