这可以在 Form1 中为按钮单击处理程序使用如下代码来完成:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.ShowDialog(); // <-- Form1 will be inaccessible until "f2" is closed
}
}
在 Form2 中,您有:
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
}
但是您并没有真正说出TextBoxes应该发生的事情...