2017-07-07 51 views
0

我有一個主窗體,從另一個窗體打開來驗證密碼的位置,我想返回到打開此窗體所在的同一點,以便我可以按照密碼驗證,請參閱代碼: -c#從子窗體返回主窗體在同一位置

 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(); 

      } 



     } 

回答

3

如果你使用的ShowDialog像你與RESULT2做,你的代碼將等待對話完成後再繼續:

this.TopMost = false; 

    FormPassword fPass = new FormPassword(); 

    fPass.ShowDialog(); 
相關問題