您的位置:首页 > 编程语言 > C#

c# 在类中将数据传递给窗体

2013-12-27 12:26 357 查看
在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!";
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: