Eric
Eric

Reputation: 2128

C#: Forms: Step-By-Step Hide/Show Forms

I am writing a small Windows Forms application in C#. Basically, it will ask the user a series of questions in a step-by-step format. I would like to have a new form for each "step," so my question is: Is there a standard logical way of doing this?

Right now, what I am doing is making a class which holds an instance of each different form. I have "next" and "previous" buttons which allow the user to go back and forth by using "show()" and "hide()" commands for the different forms.

Some problems I'm having: -I want the forms to pop up in the exact same location as the previous one (right now it is a bit skewed) -I'm afraid that my method of implementation is not the best. This is a fairly common thing to do, so I'm sure there are accepted procedures.

I'm just looking for some insight from people more experienced than me. I'll appreci

For example... The user opens the program. The first screen asks them to choose a date. User chooses date and clicks "next." The first screen closes and the next screen opens. The second screen asks the user to choose a file. User chooses file and clicks "next." Etc.

Thanks!

Edit: To further clarify...install screens are very similar to what I want.

Upvotes: 1

Views: 2832

Answers (4)

Eric
Eric

Reputation: 2128

Thanks everyone. I have decided to go the "wizard" route, and I am going to use this Wizard I found online:

http://www.differentpla.net/content/2005/02/implementing-wizard-c It has been pretty easy to use so far.

Upvotes: 0

Massimiliano Peluso
Massimiliano Peluso

Reputation: 26737

Why don't you go for the TabControl ?

The link below show you a way to change the style of the active element(to highlight the step the user is on) :

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

Upvotes: 2

Iain Ward
Iain Ward

Reputation: 9936

The way I'd do it, and I imagine most 'wizard' like applications do, is to have one form and have a placeholder below to show each step as a separate user control. Then when they start you show the first control in the placeholder, and the next and previous buttons load the next\previous control repectively creating a seamless step-by-step wizard like experience.

This means that each step will show in exactly the same position and you won't have the distraction of each step disappearing and the next appearing etc and you can manage the whole thing through one place, the form.

Have a read of these for more ideas:

http://www.codeproject.com/KB/cs/barryscsharpwizard.aspx

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

Upvotes: 2

David
David

Reputation: 73564

There are a few wizard control components out there that will allow you to do this, or you can build your own.

For a very good free wizard control, see here: http://www.codeproject.com/KB/miscctrl/DesignTimeWizard.aspx

To grow your own is relatively simple to do, but tedious. I'd recommend looking at the one I posted, examining the code, and if it won't work as-is, it does have a good design that you can learn from in deciding how to build your own.

In essence, though, you really don't want to do different forms. That's got to be a nightmare.

You should instead be using one form and having different panels on the form that are shown an hidden as necessary.

Upvotes: 2

Related Questions