C # need advice on a simple problem when navigating a form

I need to simulate a form that is similar to the interface visible when installing any software. The "Next" and "Back" buttons appear, and all the information entered by the user is processed only when he presses the completion button.
When the user presses the back button, the previous information entered is displayed.
When the user clicks on the next button, the next screen shows him / her. All information displayed is displayed in one form.

There are 3 sections that I need to show the user.

  • Section 1 - pressing the next button will display section 2
  • Section 2 - pressing the back button will display section 1, and pressing the next button will display section 3
  • Section 3 - pressing the previous button will display section 2, and pressing the completion button will process all the information entered in sections 1,2 and 3.

Currently, it is planned to implement the solution listed below:

  • Create one form
  • Add the entire item to section 1 and create the next button event that will hide the entire item shown in section 1, including the button, and show all the items in section 2.
  • Create a button event for the back button for section 2 so 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 the entire element in section 2, including the button and show the entire element in section 3
  • Create a similar button event for section 3

Is there a better solution than the one described above. If yes, please describe the approach. Any help provided would be greatly appreciated.

+6
c # winforms wizard
source share
5 answers

One way to achieve this is to use the tab control and hide the tabs so that the user cannot move between them, and instead you control the movement from one tab to the next programmatically.

I use the KryptonNavigator control, because it provides many different modes that make tab hiding easier so that only the contents of the tab can be seen, etc. However, it should be possible to hide the tabs of a standard tab control.

KryptonNavigator

+2
source share

It looks like you need a wizard control. Try one of them:

http://www.codeproject.com/KB/miscctrl/ak_wizard.aspx

https://stackoverflow.com/questions/195255/best-wizard-control-for-net-windows-forms

+2
source share

You can create your own controls for three different screens, then you can simply add these 3 controls to the form, making it easier to hide / show the corresponding controls.

Or, alternatively, you can create three separate forms, and then show your forms in order and perform actions in the Main() program, rather than using the form as a launch object. how

 static void Main() { Form1 f1 = new Form1(); if (f1.ShowDialog() == DialogResult.OK) { // do actions // show next form // etc. } } 
0
source share

You can use the usercontrol structure to achieve this behavior. You can add a simple control panel and change the contents of the panel according to the buttons pressed. You can simply change the contents of the panel using yourPanel.Controls.Add(your_user_control) . Thus, various control sets can be implemented on winform.

thanks

0
source share

Yes, as iain said, managing a wizard is likely to be your best bet, but if that doesn't work, try looking for MultiView or Accordian controls. They create controls that are specifically designed to hide / show sections on the form, so you don’t need to switch from form to form, and so you stay in the same area all the time. Keeps filling fields much easier.

0
source share

All Articles