我想设置textbox.text
from class1
,但是当我按下按钮时没有任何反应。怎么了?
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Class1 c;
private void button1_Click(object sender, EventArgs e)
{
c = new Class1();
c.x();
}
}
}
而这段代码来自class1
namespace WindowsFormsApplication1
{
class Class1
{
public static Form1 f;
public void x()
{
f = new Form1();
f.textBox1.Text = "hello";
}
}
}
我已经将textBox1
修饰符更改为公共。