我做的是windows应用窗体,是在form2中显示,怎么都显示不出来!
form2的 private void Form2_Load(object sender, EventArgs e)
{
Form1 f1 = new Form1();
Form2 f2 = new Form2();
f2.textBox1.Text = f1.textBox1.Text;
string str = "Data Source=.;Initial Catalog=gkcj;Integrated Security=True";
SqlConnection conn = new SqlConnection(str);
conn.Open();
//f2.textBox1 = f1.textBox1;
string select = "select zkzh from xsb where zkzh='" + f2.textBox1 .Text + "'";
SqlCommand cmd = new SqlCommand(select, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
form1 中 private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
f1.Hide();
Form2 f2 = new Form2();
f2.Show();
参考资料:http://zhidao.baidu.com/question/204654889.html
本回答被网友采纳