Show inactivity Dialog
I am working on a module that will log off my application if not active for 2 minutes. After 2 minutes, I set the visible property of my form as false and show the log off screen.When user log on again I simply set the开发者_开发百科 visible property of last active form as true.
Now I am showing a form A and there is a button in this form that will show another form B as dialog box.
When it is time to log off I simply set visible property of both forms(A, B) as false.And when user logs in again I set this property as true.
But problem is that form B is not showing as dialog now.
Also if in my login code, I set form B as
form b.ShowDialog();
It shows as a dialog but now the data entered into this form text fields (before logging off) is cleared.
Can somebody explain the reason for this behaviour?
I want to show form B as dialog and also want to maintain the status of fields in form.
> EDIT This code is hiding the forms.
if (Program.issueDepositForm != null)//form B static reference Checking if form B is not null
{
Program.issueDepositForm.Visible = false; //Form B
Program.saleproduct.Visible = false;//Form A f static refrence
}
This code is showing them again
Program.saleproduct.Visible = true; //Form Astatic refrence
if (Program.issueDepositForm.Visible == false) //Form B
{
Program.issueDepositForm.ShowDialog(); //Form B
//Program.issueDepositForm.Visible = true;
}
When you set Visible to false, the form is closed. This answer suggests a workaround, which is to cancel the form closing so it is available to be re-shown.
精彩评论