2011-11-21 25 views
0

我有2种形式,表格F1和F2。运行时,F1会进入系统托盘。当用户点击系统托盘中的图标F1出现时。当用户关闭表单时,它会返回到系统托盘。 我遇到的问题是当我点击系统托盘中的图标时,我想让密码保护。我只希望有密码的人查看表格。我有F2取得密码并检查有效性。 在F1我有这样的代码:形式之间通过控制

private void notifyIcon_DoubleClick(object sender, EventArgs e) 
    { 
     try 
     { 
      f2.Visible = true; 
      //TODO: I need to pass the control to the form f2 and wait till the user 
      // enters the password. Once he enters the password and hits enter, I want 
      // the control to be back to form F1. 

      if (f2.IsValid) 
      { 
       ShowMainForm(); 
      } 
     } 
     catch (Exception ex) 
     { 
      throw; 
     } 
    } 

谁能请告诉我是谁传的形式F1到F2的控制,并等待用户点击进入上f2和返回控制回F1

谢谢

回答

2

你想打电话f2.ShowDialog(),它只会在窗体关闭后返回。

+0

哦,它很容易!我知道这一点。谢谢 – Vinay

1
Dim instance As Form = QuickLoadForm 
Dim returnValue As DialogResult 
returnValue = instance.ShowDialog() 

通过这种方式,你可以检查Form关闭与否。