FORM1为主窗体,FROM2为子窗体,FROM2中需要调用FROM1中的DATATIMPICKER1的值
首先你将DATATIMPICKER1的modifiers属性设为public
在form1窗体中
private void button2_Click(object sender, EventArgs e)
{
FROM2 f2 = new FROM2(this);
f2.Show();
}
在FROM2添加一个构造函数
public FROM2 () { InitializeComponent(); } public FORM1 f1; public FROM2(FORM1 fm) { InitializeComponent(); f1 = fm; } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(f1.dateTimePicker1.Value.ToString()); }