c#跨窗口调用控件?

2025-02-25 17:50:12
推荐回答(3个)
回答1:

首先,建一个类:
using System;
public class cjj
{
public static string va;
}

然后在窗体1 中定义,并打开窗体 2:
cjj.va = “asdfgh”;
Form2 newfrm = new Form2();
newfrm.ShowDialog();

最后在窗体 2 中使用这个变量:
textBox1.Text = cjj.va;

回答2:

Form1中的文本假设命名为string1,Form2中命名一个变量string2;
在Form1中写Form2.string2=string1,则将文本赋给string2,再在Form2
中写TextBox.Text=string2;

回答3:

你的问题不是很清楚,是不是想在form1里面写文本,然后form2里面同步显示,是不是这样的?