private void button1_Click(object sender, EventArgs e) { //因为Form2已经组合了Form3,想要通过Form3中修改Form2内容,不应该在Form3中组合Form2,会导致循环引用 //应该在Form3中直接调用Form2获取对象引用的静态方法去调用具体内容 //在窗体间相互引用时,使用单例可以解决循环引用问题 Form2.GetForm2().TextBox1.Text = "456"; }
static void Main() { Control.CheckForIllegalCrossThreadCalls = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form2()); Application.Run(Form2.GetForm2()); }