Form2 f;static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
f = new Form2();
f.label1.Text="a";
f.Show();
}在关闭时你可以在Form1中用f.label1.text得到Form2中label1中的值,但要注意在Form2中label1要定义成public.
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
f = new Form2();
f.label1.Text="a";
f.Show();
}在关闭时你可以在Form1中用f.label1.text得到Form2中label1中的值,但要注意在Form2中label1要定义成public.
在form2中
class form2{
...
private Form f
public form2(Form f){
this.f = f;
...//内容与public form2(){...}里的一样
}
public override dispose(){
f.label1.Text = this.label1.Text;
...
}
...
}
---------------------------------------- 修改
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
f = new Form2(this);
f.label1.Text="a";
f.Show();
}看看行不。
在form2中定义
public string strpwd
{
get
{
return this.textBox1.Text.Trim();
}
set
{
this.textBox1.Text=value;
}
}