Reputation: 1064
I have 2 forms, Form F1 and F2. Form F1 when run goes the the System Tray. When the user clicks on the icon in the system tray F1 shows up. When user closes the form it goes back to the system tray. The problem I have is when I click on the icon in the system tray, I want to make is password protected. I want only the people with the password to view the form. I have F2 which takes the password and checks for validity. In F1 I have this code:
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;
}
}
Can anyone please tell me who to pass the control from form F1 to F2 and wait until user clicks enter on f2 and return the control back to f1
Thanks
Upvotes: 0
Views: 384
Reputation: 21
Dim instance As Form = QuickLoadForm
Dim returnValue As DialogResult
returnValue = instance.ShowDialog()
In this way you can check if the Form
is closed or not.
Upvotes: 1
Reputation: 887245
You want to call f2.ShowDialog()
, which will only return after the form is closed.
Upvotes: 2