如何让用户浏览多个“屏幕",以便在屏幕上导航.在一个表格/窗口中? [英] How to have a user navigate multiple "screens" within one form/window?

查看:98
本文介绍了如何让用户浏览多个“屏幕",以便在屏幕上导航.在一个表格/窗口中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个项目,该项目模拟公司的程序以在GUI中执行各种功能(在VS2010上使用C#).当前大约有10种左右的不同形式,每种功能一种(用作菜单,填写各种形式,管理所述形式,等等).到目前为止,我们一直在使用以下内容:

I am working on a project that simulates a company's program for performing various functions within a GUI (using C# on VS2010). Currently there are about 10 or so different forms, one for each function (serving as a menu, filling out assorted forms, management of said forms, ect). So far we've been using things along the line of:

Form1 myForm1 = new Form1();
myForm1.Show();

打开新屏幕,然后

this.Hide();

完成当前活动的表单后. (this.Close()似乎正在关闭整个程序)

when finished with the currently active form. (this.Close() just seems to close the entire program)

这会导致一些问题,因为在单击表单右上角的X后,该过程存在继续运行的问题(我认为这是由于隐藏的表单未正确关闭).我还怀疑,如果用户使用程序内导航而没有足够长地终止进程,则表单的不断生成和隐藏最终会占用所有内存.

This causes some issues in that the process has an issue of continuing to run after the X at the top right of the form is clicked (I think that this is due to hidden forms not being closed properly). I also suspect that if a user uses in-program navigation without killing the process long enough, the constant generation and hiding of forms will end up hogging up all the memory.

在野外,我很少看到依赖于不断打开新窗口/窗体来启用用户导航的程序.诸如安装程序之类的程序通常使用某种事件来导致当前显示的内容消失而新的内容出现而无需更改为新的窗体/窗口.我该怎么做呢?是将按钮/文本框/标签彼此堆叠在一个屏幕中但隐藏起来的问题,还是我缺少的更直观的东西?

In the wild, I rarely see programs that rely on opening new windows/forms constantly to enable user navigation. Programs, such as an installer, typically use an event of some sort to cause the current displayed content to disappear and new content to appear without changing to a new form/window. How can I go about doing this? Is it a matter of having buttons/textboxes/labels all stacked on each other in the one screen, but hidden or is there something more intuitive that I am missing?

推荐答案

您可以执行此操作(但并不总是可行)的方法是制作

The way you can do this (but isn't always feasible) is to make a UserControl for each screen. When its time to move on to the next screen, you simply hide the current user control and show the next one. So if you have 8 screens for example, you make each one into a user control.

然后在MainForm的Load事件中,最初隐藏除第一个事件以外的所有事件.当其时间移至第二个屏幕时,您将隐藏第一个控件,并显示第二个控件,等等.

Then on your MainForm's Load event, you initially hide all except the first one. When its time to move onto the second screen, you hide the first control and show the second, etc etc

这篇关于如何让用户浏览多个“屏幕",以便在屏幕上导航.在一个表格/窗口中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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