|
I am building an app that requires a user to complete info on a form, then click "Next", complete more info, then click "Next" again. Also, the user can go back at any time by clicking "Previous". It's a wizard-like interface. Anyway, I am currently doing this to go to the next form: Form2 theForm = new Form2(SomeObject); theForm.Show(); this.Hide(); This works fine, but I suspect that I shouldn't be doing this. For starters, I am really just hiding Form1, so it is hanging around in memory. Second, if I want to click "Previous" to get back to Form1, how would I make it appear again? Anyway, what's the recommended method for handling forms like this? Thanks. | | tom_g Thursday, June 30, 2005 11:37 AM | There are a couple of ways to create a wizard. The most common technique is to use a single form for the entire wizard. The controls necessary for each "page" get placed in a panel and then the different panels are shown/hidden as necessary.
My personal approach is to "orchestrate" the wizard. I have a component that tracks the sequence of the forms and passes the object being managed from form to form. The component responds to events raised by the forms (NextClicked, BackClicked, FinishClicked, CancelClicked, etc..) in order to determine which form to display next. Each of these events passes a custom EventArgs that contains the instance of the object being managed by the wizard. Most of this can be encapsulated in a base form to make life even easier if you have a need for a lot of wizards. My particular application has 60+ wizards, so this approach was a lifesaver.
Jacob | | Jacob Grass Thursday, June 30, 2005 10:20 PM | I haven't tried that particular feature yet, but Genghis ( http://www.genghisgroup.com/) has a wizard framework. Genghis is free and comes with sourcecode. | | Daniel Rieck Thursday, June 30, 2005 1:08 PM | I should think you would want to separate your data from your UI, so that you can pass around your partially populated data from wizard page to wizard page. This separation allows you to close one form without losing the data, and also gives you something from which to populate your previous form when the user clicks "Previous".
In the spirit of reusability, it makes sense also to separate your form sequence from the forms themselves, so that you can change the sequence without having the change the code in the forms themselves, i.e., don't hardcode on any particular form which form is previous and which is next.
I hope this helps. | | durstin Thursday, June 30, 2005 9:20 PM | There are a couple of ways to create a wizard. The most common technique is to use a single form for the entire wizard. The controls necessary for each "page" get placed in a panel and then the different panels are shown/hidden as necessary.
My personal approach is to "orchestrate" the wizard. I have a component that tracks the sequence of the forms and passes the object being managed from form to form. The component responds to events raised by the forms (NextClicked, BackClicked, FinishClicked, CancelClicked, etc..) in order to determine which form to display next. Each of these events passes a custom EventArgs that contains the instance of the object being managed by the wizard. Most of this can be encapsulated in a base form to make life even easier if you have a need for a lot of wizards. My particular application has 60+ wizards, so this approach was a lifesaver.
Jacob | | Jacob Grass Thursday, June 30, 2005 10:20 PM | Hey Jacob,
I have a question for you that does not pertain to this forum.
Scott Southwick
stlthumper77@yahoo.com | | StLThumper Thursday, December 15, 2005 5:16 PM |
|