//Form1中使用Form2的信息。 private void button1_Click(object sender, System.EventArgs e) { Form2 f = new Form2( this ); f.Show();
int w = f.Width; }//Form2中使用Form1的信息。 public class Form2 : System.Windows.Forms.Form { Form1 f1; public Form2( Form1 f ) { InitializeComponent(); f1 = f; } private void Form2_Load(object sender, System.EventArgs e) { int h = f1.Height; } }
class frmMain:System.winodws.forms
{
public string c="adf";
public string showfrmSub()
{
frmSub fb=new frmSub();
fb.f=this;
return fb.get();
}
}class frmSub:System.winodws.forms
{
public frmMain f;
public string get
{
return f.c;
}
}
1.使用公共静态成员
2。创建一个新的实例,调用它的公共或internal的非静态函数
private void button1_Click(object sender, System.EventArgs e)
{
Form2 f = new Form2( this );
f.Show();
int w = f.Width;
}//Form2中使用Form1的信息。
public class Form2 : System.Windows.Forms.Form
{
Form1 f1;
public Form2( Form1 f )
{
InitializeComponent(); f1 = f;
} private void Form2_Load(object sender, System.EventArgs e)
{
int h = f1.Height;
}
}
http://www.csdn.net/Develop/read_article.asp?id=26434
http://www.csdn.net/Develop/read_article.asp?id=26436