显示不活动对话框

发布于 2024-11-08 03:09:12 字数 1017 浏览 0 评论 0原文

我正在开发一个模块,如果 2 分钟不活动,该模块将注销我的应用程序。 2 分钟后,我将表单的可见属性设置为 false 并显示注销屏幕。当用户再次登录时,我只需将最后一个活动表单的可见属性设置为 true。

现在我正在显示一个表单A,并且该表单中有一个按钮将另一个表单B显示为对话框。

当需要注销时,我只需设置两个表单的可见属性(A, B)为 false。当用户再次登录时,我将此属性设置为 true。

但问题是表单 B 现在不显示为对话框。

另外,如果在我的登录代码中,我将表单 B 设置为

form b.ShowDialog();

它显示为对话框,但现在输入到该表单文本字段中的数据(在注销之前)被清除。

有人可以解释这种行为的原因吗?

我想将表单 B 显示为对话框,并且还想维护表单中字段的状态。

>编辑 该代码隐藏了表单。

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
}

这段代码再次显示了它们

Program.saleproduct.Visible = true; //Form Astatic refrence
if (Program.issueDepositForm.Visible == false) //Form B
{
    Program.issueDepositForm.ShowDialog();      //Form B
    //Program.issueDepositForm.Visible = true;

}

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;

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱给你人给你 2024-11-15 03:09:12

当您将 Visible 设置为 false 时,表单将关闭。 此答案提出了一种解决方法,即取消表单关闭,以便可以重新显示。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文