我有一个主表单,从另一个表单打开以验证密码,我想返回到打开此表单的同一点,以便我可以根据密码验证进行操作,请参阅代码: - < / p>
this.TopMost = false;
FormPassword fPass = new FormPassword();
fPass.Show();
//I need it should wait here , but dosent,
// i tried adding here
// while(fPass.Visible); //but didn't helped
if (Variables.IsPasswordCorrect == true)//IsPasswordCorrect defined in variables.cs, to make it common in both the forms
{
DialogResult result2 = MessageBox.Show("Start the Process?", "START?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
if (result2 == DialogResult.Yes)
{
StartAll();
}
}
答案 0 :(得分:3)
如果您使用ShowDialog,就像使用result2一样,您的代码将等待对话框完成,然后继续:
this.TopMost = false;
FormPassword fPass = new FormPassword();
fPass.ShowDialog();