C# 需要关于表单导航的简单问题的建议
我需要模拟一个类似于安装任何软件时看到的界面的形式。有下一步和后退按钮,只有当用户单击完成按钮时,才会处理用户输入的所有信息。
当用户单击后退按钮时,将向他/她显示之前输入的信息。
当用户单击下一步按钮时,将向他/她显示下一个屏幕。所有显示的信息都以一种形式显示。
我需要向用户展示 3 个部分。
- 第 1 部分 - 按下一个按钮将显示第 2 部分
- 第 2 部分 - 按后退按钮将显示第 1 部分,按下一个按钮将显示第 3 部分
- 第 3 部分 - 按上一个按钮将显示第 2 部分,按完成按钮将处理所有内容在第 1,2 和 3 节中输入的信息
。目前计划实施下面列出的解决方案:
- 创建一个表单
- 添加第 1 节的所有元素并创建一个下一个按钮事件,该事件将隐藏第 1 节中显示的所有元素,包括按钮和显示第 2 部分的所有元素。
- 为第 2 部分的后退按钮创建按钮事件,以便隐藏第 2 部分中的所有元素(包括按钮)并显示第 1 部分中的所有元素和下一个按钮以隐藏第 2 部分中的所有元素包括按钮并显示第 3 节中的所有元素
- 为第 3 节创建类似的按钮事件
有没有比上面描述的更好的解决方案。如果是,请描述方法。提供的任何帮助将不胜感激。
I need to simulate a form that is similar to the interface seen during installation of any software. There are next and back buttons and the all the information entered by the user is processed only when he/she clicks the finish button.
When the user clicks the back button, the previous entered information is showed to him/her.
When the user clicks the next button the next screen is show to him/her. All displayed information is shown in one form.
There are 3 section which I need to show the user.
- Section 1 - pressing the next button will show section 2
- Section 2 - pressing the back button will show section 1 and pressing the next button will show section 3
- Section 3 - pressing the previous button will show section 2 and pressing the finish button will process all the information entered in section 1,2 and 3.
Currently planning to implement the solution listed below :
- Create one form
- Add all the element for section 1 and create a next button event that will hide all the element shown in section 1 including the button and show all the elements section 2.
- Create button event for the back button for section 2 such that it hides all the elements in section 2 including the button and displays all the elements in section 1 and the next button to hide all the element in section 2 including the button and show all the element in section 3
- Create similar button event for section 3
Are there any better solution than the one describe above. If yes, please describe the approach. Any help provided will be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
实现此目的的一种方法是使用选项卡控件并隐藏选项卡,以便用户无法在它们之间导航,而是由您以编程方式控制从一个选项卡移动到下一个选项卡。
我使用 KryptonNavigator 控件,因为它提供了许多不同的模式,可以轻松隐藏选项卡,以便只有选项卡内容可见等。但是,应该可以隐藏标准选项卡控件的选项卡。
KryptonNavigator
One way to achieve this is using a tab control and hiding the tabs so that the user can't navigate between them and instead you control moving from one tab to the next programatically.
I use the KryptonNavigator control as it provides many different modes that make it simple to hide tabs so that only tab content is visible, etc. However, it should be possible to hide the tabs of the standard tab control.
KryptonNavigator
听起来你需要一个向导控件。尝试以下之一:
http://www.codeproject.com/KB/miscctrl/ak_wizard .aspx
https://stackoverflow.com/questions/195255/网络 Windows 表单的最佳向导控制
Sounds like you need a wizard control. Try one of these:
http://www.codeproject.com/KB/miscctrl/ak_wizard.aspx
https://stackoverflow.com/questions/195255/best-wizard-control-for-net-windows-forms
您可以使用用户控制结构来实现这种行为。您可以添加一个简单的面板控件,并根据按下的按钮更改面板的内容。您只需使用
yourPanel.Controls.Add(your_user_control)
即可更改面板的内容。所以在一个winform上可以实现不同的控件集。
谢谢
You can use usercontrol structure to achieve this kind of behaviour. You can add a simple panel control and change the content of the panel according to the buttons pressed. You can simply change the content of the panel by using
yourPanel.Controls.Add(your_user_control)
.So different control sets can be implemented on a winform.
Thanks
您可以为三个不同的屏幕创建自定义控件,然后只需将这 3 个控件添加到表单中,从而更容易隐藏/显示相应的控件。
或者,您可以创建三个单独的表单,然后按顺序显示表单并执行程序
Main()
函数中的操作,而不是使用表单作为启动对象。喜欢You could create custom controls for the three different screens, then you could just add those 3 controls to the form, making it easier to hide/show the appropriate controls.
Or alternatively, you can create three separate forms, and then show your forms in order and perform the actions in the programs
Main()
function rather than using a form as your startup object. Like是的,就像 iain 所说,向导控件可能是您最好的选择,但如果这不起作用,请尝试寻找 MultiView 或 Accordian 控件。他们制作专门用于隐藏/显示表单上的部分的控件,因此您不必从一个表单转到另一个表单,因此您始终保持在同一范围内。使保持字段填充变得更加容易。
Yeah, like iain said, the wizard control is probably your best bet, but if that doesn't work, try looking for MultiView or Accordian controls. They make controls that are specifically for hiding/showing sections on a form, so you don't have to go from form to form, and thus you stay in the same scope the whole time. Makes keeping the fields populated a lot easier.