在Form1中 textbox1的modifilers设为Public,
public static Form1 f=null;
public Form1()
{
InitializeComponent();
f = this;
}
private void button1_Click(object sender, EventArgs e)
{
test cl = new test();
cl.t_test();
}
类文件:
public class test
{
public void t_test()
{
Form1.f.textBox1.Text = "this is a test message!";
}
}
c# 在类中将数据传递给窗体
最新推荐文章于 2022-07-20 17:00:26 发布