public void ShowMyDialogBox() { Form2 testDialog = new Form2(); // Show testDialog as a modal dialog and determine if DialogResult = OK. if (testDialog.ShowDialog(this) == DialogResult.OK) { // Read the contents of testDialog's TextBox. this.txtResult.Text = testDialog.TextBox1.Text; } else { this.txtResult.Text = "Cancelled"; } testDialog.Dispose(); }
Form2 ft = new Form2(); ft.TopMost = true; ft.ShowDialog();
Form2 ft = new Form2(); ft.TopMost = true; ft.ShowDialog();
可以窗体弹出的时候showModelDialog
{
Form2 testDialog = new Form2(); // Show testDialog as a modal dialog and determine if DialogResult = OK.
if (testDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
this.txtResult.Text = testDialog.TextBox1.Text;
}
else
{
this.txtResult.Text = "Cancelled";
}
testDialog.Dispose();
}
ft.TopMost = true;
ft.ShowDialog();
ft.TopMost = true;
ft.ShowDialog();
说的就行