简体   繁体   English

Winform处理

[英]Winform handling

I have 3 forms. 我有3种形式。 We can enter to form2 through form1.(Then form1 will disappear.) When we close form2, form1 will reappear. 我们可以通过form1进入form2。(然后form1将消失。)当我们关闭form2时,form1将重新出现。 Similarly we can enter to form3 through form2.(Then form2 will disappear.) When we close form3, form2 should reappear.(This is the part where I fail.) 同样,我们可以通过form2进入form3。(然后form2将消失。)当我们关闭form3时,form2应该重新出现。(这是我失败的部分。)

When I close the form3, the form which appear is the form1 instead of form2. 当我关闭form3时,出现的窗体是form1而不是form2。 (same instances have to reappear. 'Creating new object of form and make it appear' is not allowed :) ) (必须重新出现相同的实例。不允许创建“表单的新对象并使之显示” :))

Please help. 请帮忙。

code in form1: 形式1中的代码:

        this.ShowInTaskbar = false;
        this.Visible = false;
        Form2 f2 = new Form2();
        f2.ShowDialog();
        this.Visible = true;
        this.ShowInTaskbar = true;

code in form2: form2中的代码:

        this.Visible = false;
        this.ShowInTaskbar = false;
        Form3 f3 = new Form3();
        f3.ShowDialog();
        this.Visible = true;
        this.ShowInTaskbar = true;

Not sure, but try make form2's parent be form1: 不确定,但是尝试使form2的父级成为form1:

form2.Parent=form1;

or 要么

f2.ShowDialog(form1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM