日期:2014-05-17 浏览次数:20850 次
public partial class Form1 : Form //在label的窗口定义属性字段,此属性为给label的text赋值
{
public Form1()
{
InitializeComponent();
}
private string para;
public string _para
{
get { return para; }
set { para = value; }
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = para;
}
}
public partial class Form2 : Form //在textbox的窗口创建form1对象以将textbox的text值赋值给from的属性字段
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
f1._para = textBox1.Text;
f1.ShowDialog();
}
}
Form2 form2 = new Form2();
private void Form1_Load(object sender, EventArgs e)
{
form2.TopMost = true ;
form2.Show();
}
private void button1_Click(object sender, EventArgs e)
{
form2.Label1.Text = textBox1.Text;//Label1设为public
}