在面板之间切换 [英] Switch between panels

查看:103
本文介绍了在面板之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有1种形式的3个面板,要经过一个过程才能输入某些数据.单击面板中的下一个按钮时,应显示下一个面板. 最初,我启用了第一个面板的可见性,并禁用了其他面板的可见性.
单击下一个按钮时,将执行以下代码.

I have 3 panels in 1 form to go through a process to input certain data. When the next button in a panel is clicked the next panel should be displayed. Initially I have enabled the visibility of first panel and disabled the visibility of other panels.
When the next button is clicked the below code will be executed.

      panel1.Visible = false;
      panel2.Visible = true;

出于发展的目的,我将它们并排放置(不是一个接一个),它可以完美地工作.
但是,当我将它们一个接一个地放置时,上面的代码似乎没有被唤醒,这意味着当单击下一个按钮时,它只是显示一个空表格.
然后我也添加了下面的代码.

For the purpose of development I have put them side by side(not one upon another) and it woks perfect.
But when I put them one upon another the above code does not appear to be wok, which means when the next button is clicked it just shows a empty form.
Then I added below code too.

    panel1.SendToBack();
    panel2.BringToFront();

但是没有用.有人可以帮我吗?

谢谢.

But it didn't work. Can someone help me with this.

Thank you.

推荐答案

这在设计器中总是会出错,底部面板将成为顶部面板的父级.因此,如果您隐藏了最下面的一个,就永远看不到最上面的一个.

This always goes wrong in the designer, the bottom panel will become the Parent of the top one. So if you hide the bottom one you can never see see the top one.

这可以通过使用视图">((其他Windows)>文档大纲")来解决,将顶部面板拖回到表单中.仍然很痛苦,您通常必须手动编辑位置",然后在设计器中对表单进行任何更改,这往往会使面板显得很笨拙.

This can be worked around with View > (Other Windows) > Document Outline, drag the top panel back to the form. Still pretty painful, you typically have to edit the Location by hand and making any changes to the form in the designer later tends to slurp the panel back.

有更好的方法可以做到这一点.强烈建议创建UserControl,因为它们具有自己的设计图面.或使用RAD方式,而是使用TabControl进行此操作.您要做的就是在运行时隐藏这些选项卡,这是 Q + A .

There are better ways to do this. Creating UserControls instead is highly recommended, they have their own design surface. Or use the RAD way and do this with a TabControl instead. All you have to do is hide the tabs at runtime, the subject of this Q+A.

这篇关于在面板之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆