6

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 :

  1. Create one form
  2. 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.
  3. 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
  4. 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.

Hans Olsson
  • 54,199
  • 15
  • 94
  • 116
abduls85
  • 548
  • 8
  • 15
  • 1
    What you're looking for is called a "Wizard". You may be able to find some good tutorials searching with that keyword. – Justin Feb 10 '11 at 14:02
  • If this is a web application (can't tell from your question) there is a wizard control in the standard web control library that will do exactly what you want. – Tim M. Feb 10 '11 at 14:10
  • I am doing a desktop application. Thanks justin, wizard is exactly what i want. Thanks for your help. – abduls85 Feb 10 '11 at 14:18

5 Answers5

2

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

Community
  • 1
  • 1
Iain
  • 2,500
  • 1
  • 20
  • 24
2

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

Matt F
  • 585
  • 1
  • 6
  • 20
  • i've used this in the past. i havent used any wizard controls. What's nice about this is you can easily separate out the controls per tab in the designer. A great simple solution. – jrsconfitto Feb 10 '11 at 15:27
0

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

static void Main()
{
  Form1 f1 = new Form1();
  if (f1.ShowDialog() == DialogResult.OK) 
  {
    // do actions
    // show next form
    // etc.
  }
}
Justin
  • 6,611
  • 3
  • 36
  • 57
Kratz
  • 4,280
  • 3
  • 32
  • 55
  • 1
    What if the user presses back button... He must need to work on dialog results for such situations and may become cumbersome... Instead a wizard control / Tab control will be useful. – The King Feb 10 '11 at 15:26
0

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

0

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.

LoveMeSomeCode
  • 3,888
  • 8
  • 34
  • 48