Click here to Skip to main content
Click here to Skip to main content

GN Wizard Framework

By , 21 Dec 2006
 

Introduction

This article will help you give your application a common wizard interface. One of the main reasons wizards were invented was to make common tasks easier to work with.

Background

The idea for my wizard came soon after I realized I was reproducing code to do the same thing again and again! As working with database applications is my main job, the need for wizard based procedures kept arising more and more. I felt the need to create a common wizard interface to suit my needs.

Implementation

Just drop the WizardTemplate control on a form, and you are ready to go.

Usage

  • Add the control to the toolbox (GNWizardFrameWork.dll).
  • Drop the WizardTemplate on a WinForm.
  • Add the pages
  • You are done!

Points of interest

The wizard component is written in VB.NET and inherits from UserControl. Attached to the wizard is a 3DLine control.

Page Layouts

Wizards usually have two different page layouts, one for exterior pages (the main/welcome page), and one for interior pages (the individual steps within the first and last pages).

Exterior Pages

Exterior pages usually have a sidebar graphic with a boxed logo. The GNWizardFramework doesn't support this; instead, I have made the exterior page as a blank canvas so the developer can set the complete layout, and not be limited to having a sidebar they might not want.

Interior Pages

The interior pages are pretty much the same as the exterior pages except for a few minor alterations. Firstly, as exterior pages fill the whole wizard except for the button bar based at the bottom of the wizard, the interior pages have a header panel, and the working panel locations is compensated by a header.

PageStyle enum

  • eWPS_Interior

    The wizard and page should be formatted as an interior page.

  • eWPS_Exterior

    The wizard and page should be formatted as an exterior page.

How the code is brought together

The wizard consists of three classes and two controls:

Class/Control Description
WizardTemplateDesigner (class) Designer for the Wizard template
WizardPage (class) Wizard page item
WizardPageCollection (class) Holds all the WizardPage details, and handles all events passed by a WizardPage
WizardTemplate (control) Wizard control
ThreeDLine (control) Simple 3D line control

Handling buttons

All pages (interior and exterior) have their own button handlers. Buttons can be accessed by the page you want to change or set:

WelcomePage.HasNextButton = True
WelcomePage.HasPreviousButton = False
WelcomePage.HasCancelButton =True
WelcomePage.HasFinishButton = False

Main Features

  • Easy to use: Simple design-time interface.
  • GUI: An easy to use GUI, what you see at design-time is what you see at runtime.
  • PC Support: Works under (tested so far) Win95/98, WinXP, Win2000, and Win2003 Server

Other Features

  • Runtime customization: You can change any part of the wizard at runtime.
  • Attach/add pages at runtime:
    'Inserting a custom page At runtime:
    
    '-- Inserts A New Page after the Current Page
    WizardTemplate.Pages.Insert(_
      WizardTemplate.Pages.IndexOf(CurrentWizPanel) + 1, _
      NewWizardPage)
    
    'Adding a custom page At runtime:
    '-- Adds A New Page To The End Of The wizard
    WizardTemplate.Pages.Add(NewWizardPage)

Conclusion

Not much here to learn from, but hopefully the library will be of some use. As this is my first article, please be lenient. I hope all of you at least enjoyed reading the article, and maybe you'll find the framework useful.

Licence (LGPL)

The GNWizardFramework library is copyright 2005-2006 to Gary Noble, but its source code and the binaries are free for commercial and non commercial use.

Only vote for this article if you like the library.

History

  • 1.01 (21-Dec-2006)
    • Updated the 'Previous Button' disabled issue pointed out by Bill Reinhold (Thanks Bill).
    • Updated the 'Toolbox bitmap' - Toolbox bitmaps are now handled properly.
  • 1.0 (21-Mar-2006) - Initial release.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Gary Noble
Software Developer
United Kingdom United Kingdom
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralSet Focus of Next, Cancel and Finishmemberjacodutoit5 Mar '08 - 20:46 
Does anyone know how to programatically set the focus of the Next, Cancel or Finish button?
 
This will be useful so that the user can just press the Enter-key, while the focus is on the Next-button to go to the next page, while being used in a program.
 
Thank you.
GeneralRe: Set Focus of Next, Cancel and Finishmemberjacodutoit6 Mar '08 - 22:34 
I'm answering my own question Laugh | :laugh:
 
Here is what I did. In the Load - method of the form that hosts the GNWizard control add the following.
 
Me.AcceptButton = Me.WizardTemplate1.Controls("ButtonPanel").Controls("btnNext") - Where WizardTemplate1 is the control name.
GeneralOnMovePrevious, OnBeforeMoveNextmemberemblabac15 Jan '08 - 4:58 
Hi Gary,
First I just want to say what an awesome tool here - thanks for sharing!
And second, any hints on how to create a OnMovePrevious sub - I'm having some issues.
Also how about any hints for a OnBeforeMoveNext sub for validation purposes.
Thanks!
GeneralRe: OnMovePrevious, OnBeforeMoveNextmemberNiyazi Yarar18 Oct '11 - 10:54 
I couldn't figure out how to validate a page. I appreciate for help...
mn.yarar

QuestionTrap button clicks?memberAIroff22 Nov '07 - 23:18 
First of all, great control, Gary - thanks!
 
I'm confused how to process the button clicks.
 
On my first interior page, I show text boxes for username/password. I want to authenticate the user before I proceed to the next page.
 
Similarly, on subsequent pages, I want to validate information before showing the next page.
 
Where are the events for the next/previous buttons?
 

Thanks Again.
QuestionUsagememberstixoffire13 Nov '07 - 18:43 
I will attempt to use this in some projects, however I have some questions.
 
Is it OK if in my About dialogs that I give you credit for the Wizard Interface and put a link to your website ???
I feelthat if I use it - that is the least I could do for the investment you made in time to develop this control.
AnswerRe: UsagememberGary Noble13 Nov '07 - 22:17 
Acknowledgment would be good but is not necessary.
 
Thank you for your honesty, I hope you can use it.
 
Kind regards
Gary
QuestionSpanish text for buttons (next, back, ...)memberamarino6 Oct '07 - 13:17 
Hi,
 
Good control. Fine for me.
 
Is possible to change the buttons text in order to use this control in another language rather than english?
QuestionEvent OnMovePreviousmemberpatmorier1 Oct '07 - 23:49 
Thanks a lot for this wonderfull job, this wizard is just perfect.
 
Do you think about implementing the OnMovePrevious Event in your framework?
I think this event could be very helpful. If not the case, do you have any idea how to handle an action on clicking the previous button?
 
Thank again,
 
Pat
GeneralControls disappear when added to a Wizard PagememberLonny Angell6 Aug '07 - 4:12 
I'm creating a Wizard added a few pages. When I add controls to the Wizard page, they no longer show up when I run?? The controls still exist on the form, they must just be behind the Wizard Page???
GeneralRe: Controls disappear when added to a Wizard PagememberMrPalermo1 Dec '07 - 13:53 
I am having the same problem
QuestionBest method to skip pages?memberPhil Jeffrey1 Aug '07 - 17:32 
First of all, thanks for an awesome control Garry.
 
I have a bit of a noobie question. Let's say my first page has radio buttons. Depending on which button is checked, I want other subsequent pages to be skipped. What is the best method to do this?
 
I have tried .Show() and .Hide() but this doesn't seem to work, because when you click Next the Page becomes visible. Using .Visible = True/False gives the same results.
 
I have had a look at .GoToPage, I think it's what I need, but I don't know where to put the code. I'm thinking it's OnMoveNext, but how does this method know what current page I'm on?
 
Thanks for your help.

GeneralProblems when using DPI 120memberGeert van Horrik21 Jun '07 - 2:42 
Hello,
 
This is an excellent control, and I use this in several projects. However, it seems to have some problems when using DPI 120.
 
Do you still improve this control or not? If so, will you fix this "bug" and when can I expect it?
 
Best regards,
 
-----
Geert
 
Need an advanced auto-update feature for your software? Try Updater!
Visit my website: http://www.catenalogic.com

GeneralRe: Problems when using DPI 120memberGary Noble21 Jun '07 - 4:45 
Can you elaborate on the problems you are having?

GeneralRe: Problems when using DPI 120memberGeert van Horrik21 Jun '07 - 4:52 
Hello,
 
I have been investigating this problem more deeply. The problem is that the wizardpages are stretched over the buttons. So, I will now solve the problem by setting the size of the wizard pages automatically for 120 DPI. In that case, the background of the wizardpages will not be in front of the wizard buttons.
 
Best regards,
 
-----
Geert
 
Need an advanced auto-update feature for your software? Try Updater!
Visit my website: http://www.catenalogic.com

GeneralRe: Problems when using DPI 120memberGary Noble21 Jun '07 - 5:04 
Excellent.
 
I like your updater tool.
It looks very easy to implement and maintain.
 
You could give it a better sidebar by implementing my outlookstyle sidebar control that can be found here: http://www.itchin.net/NBMain.html[^]
 
Kind Regards
Gary
GeneralRe: Problems when using DPI 120memberGeert van Horrik21 Jun '07 - 5:27 
Thanks! I indeed implemented some sort of outlookstyle sidebar control to it, but Updater Tool is written in C++ (and I see your bar is a C# control).
 
Anyway, there is also a new version available (now called Updater Studio, which has a Visual Studio a-like interface).
 
But I will definitely bookmark your website, I like your controls Smile | :)
 
Best regards,
 
-----
Geert
 
Need an advanced auto-update feature for your software? Try Updater!
Visit my website: http://www.catenalogic.com

GeneralRe: Problems when using DPI 120memberGary Noble21 Jun '07 - 5:48 
All my code is vb.net!

GeneralRe: Problems when using DPI 120memberGeert van Horrik21 Jun '07 - 5:50 
Indeed, sorry for my mistake. But, for .net controls, there is no differences between assemblies developed in C# and VB.net.
 
Best regards,
 
-----
Geert
 
Need an advanced auto-update feature for your software? Try Updater!
Visit my website: http://www.catenalogic.com

GeneralDesigner Bugmemberdwpmartin19 Jan '07 - 6:51 
If you have more than 2 pages click next in the designer always skips the second page.
QuestionIs this a bug??memberwreinhold20 Dec '06 - 9:42 
I was having trouble because the Previous button kept getting disabled on the last page of my wizard. Tracing through the code I found the reason in the CheckState sub in the Wizard.vb file:
 
If m_lStartItem > 0 Then
btnPrevious.Enabled = m_lCurrentItem > m_lStartItem And SelectedPane.HasNextButton
Else
btnPrevious.Enabled = m_lCurrentItem > 0 And SelectedPane.HasNextButton
End If
 

This code bases the state of the Previous button on the HasNextButton property of the selected page. I changed these two lines to use the HasPreviousButton property and it seems to work fine now.
 
Is there a reason this was coded this way? (am I setting myself up for some unintended consequence by making this change?)
 
Thanks,
Bill Reinhold

AnswerRe: Is this a bug??memberGary Noble20 Dec '06 - 22:07 
Hi Bill
 
>> Is there a reason this was coded this way?
 
No - Just an oversight on my behalf.
 
The changes you made should be fine, and will probably not cause any problems.
 
Kind regards
Gary

GeneralRe: Is this a bug??memberwreinhold21 Dec '06 - 1:30 
Thanks for the reply Gary. Besides being convenient to use, this is a great source of techniques for building custom controls. Sure appreciate you making it available.
 
Bill
QuestionAdd to toolbar problem [modified]memberwreinhold15 Dec '06 - 4:07 
I was getting an error adding the control to the toolbar in VS.Net 2003. I had to copy the three picture files from the top level GN Wizard folder to the root directory on my c: drive to get it to work.
 
What am I doing wrong?
 

-- modified at 14:49 Tuesday 19th December, 2006
QuestionWill this work with VS2005memberchilling25 Nov '06 - 0:03 
Hi Gary - looks an awesome control, just what I was looking for.
 
Are there any changes needed to use this in VS 2005 ?
AnswerRe: Will this work with VS2005memberGary Noble25 Nov '06 - 23:04 
As far as I'm aware there are no changes needed to run this in VS 2005.
 
All you will have to do Is rebuild/recompile it, so that it runs using the appropriate framework.
 
Kind Regards
Gary
GeneralRe: Will this work with VS2005memberBill960316 Apr '10 - 12:45 
VS2005 VS2010? This will not work with 2010. Make sure that you use VS to target a lower framework to get it to work. I am trying to get this working now.
"Cookies are life!"

GeneralCode and Additionsmembervaderjm28 Sep '06 - 7:22 
Gary,
 
I have been working with your control for the past 2 days and I really like it. I did run across one error where if btnNext was disabled for the last page in the wizard, it would automatically disable the btnPrevious.
 
I could see that the point was to auto-disable btnPrevious on the first page and btnNext on the last page, so I changed the btnNext code in the Sub CheckState to read:
 
If btnNext.Enabled Then
btnNext.Enabled = m_lCurrentItem < (Pages.Count - 1)
End If
 
then enabled both buttons for each page and let the control handle disabling the correct button.
 
I also added OnBeforeMoveNext, OnMovePrevious, and OnBeforeMovePrevious to handle my needs. I was only able to do this because of your well documented code. Thanks a ton. I learned buckets about control coding. This will save me a lot of time in my current application as well as in the future.
 
I will document my use of your library per your wishes in both my commercial and non-commercial applications.
 
Again Thank you.
 
Jason Myrup
GeneralVS2005 Designer Errormemberdisplaced8025 Aug '06 - 4:23 
Hi,
 
This looks like an absolutely fantastic control! I'm having some difficulty using it in the designer, however.
 
I can add a WizardTemplate successfully, and I can add a page, too. However, when I try to save that form, I get the error:
 
'WizardTypeConverter' is unable to convert 'GNWizardFramework.WizardPage' to 'System.ComponentModel.Design.Serialization.InstanceDescriptor'
 
I'm looking through the source in a (so far) vain attempt to get this working, although I'm not particularly familiar with how components are coded.
 
Any pointers on how this can be fixed?

 
Cheers,
Chris
AnswerRe: VS2005 Designer Errormemberkmcbrearty10188 Sep '06 - 19:20 
Chris I found the source of the error. It is in Panels and Collections\WizardPanel.vb. It is the ConvertTo function that is causing the problem. Add a Try..Catch statement to the function and ignore err.number = 13. Mine is as follows:
 
-------------------------------------------------------------------------------------------------
 
Try
If destType Is GetType(InstanceDescriptor) AndAlso (TypeOf value Is WizardPage) Then
Dim col As WizardPage = CType(value, WizardPage)
Dim ci As ConstructorInfo = GetType(WizardPage).GetConstructor(New Type() {})
Return New InstanceDescriptor(ci, New Object() {}, False)
End If
Return MyBase.ConvertTo(context, culture, value, destType)
Catch ex As Exception
If Err.Number <> 13 Then
MsgBox("Error Number: " & Err.Number & vbCrLf & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace)
End If
Return Nothing
End Try
 
-------------------------------------------------------------------------------------------------
 
As far as I can tell everything still works fine. I know this is the best option but it seems to work. I am trying to determine how to correct it rather than ignore it. No luck yet.....
 

Hope this helps Smile | :)
 
Kevin McBrearty

QuestionOnMovePrevious?memberScottGBR26 Jul '06 - 6:24 
I really like this library as I am forever writing programs for the computer illiterate!
 
However for some of the applications of these wizards, changes to the order of the pages which are displayed have to be made. The library makes provision for altering pages that are shown when clicking the next button using the 'OnMoveNext' declaration. However I cannot find an 'OnMovePrevious' declaration or similar.
 
To summarise; is there any way I can decide at runtime what pages to skip when clicking both next and previous?
 
Many thanks,
 
Scott
QuestionLocalizationmemberCh Fischer17 Jul '06 - 1:39 
Hi!
 
I like this wizard very much! Just what I have looked for!
 
One question: How do I make the properties "HeaderCaption" and "SubHeaderCaption" localizable? OK, I could load my strings on startup from a resource file, but is there also an automated way in the designer (just like for standard controls)?
 
Thank's a lot!
 
Christian
GeneralRemove method looking strangememberDylan Lyons4 Jul '06 - 23:16 
Hi, nice control,
 
Is there a bug in WizarPanelCollection, at the method starting on line 257? (And is the vb file spelt incorrectly?)
 
There is a control declared but never initialised:
 
Dim o As Control
 
Then this is done:
 
o.Parent.Parent.Controls.Add(value)
 
Doesnt look right, any comments?
GeneralRe: Remove method looking strange [modified]memberBobishKindaGuy25 Dec '06 - 12:12 
Yes, in VB2005 this is flagged as "Variable 'o' is used before it has been assigned a value."
 
So I think the code will fail at runtime if this sub runs and the try/catch block if/then is true.
 
Since the sub is not commented, I'm not sure what is being attempted by the code in the Try/Catch.
 
The passed-in wizardpage is being checked for nothingness, and if it is not nothing, then a control is being added to the parent control two levels up. The question is, which control's grandparent do we want to add the wizardpage to?
 
By the way, kudos to Gary for something that I'll really use a lot !Big Grin | :-D

GeneralRe: Remove method looking strangememberDavid Leckenby3 Sep '07 - 1:51 
This Remove method won't fail at runtime because there is no code in the Catch clause to handle the exception. Or maybe I should say it WILL fail but you just won't know about it. If you add "MsgBox(ex.Message)" you will get a notification of the Null reference exception when you remove a wizard page from the designer.
 
It would be nice to know what the code is trying to achieve?? For the moment I see no alternative other than to comment out the line "o.Parent.Parent.Controls.Add(value)" as it won't do anything as it stands.
 
Other than this one issue, I see nothing else I want to change - thanks for the great resource.
QuestionChange wizardpagesmemberkoodiguru12 Jun '06 - 2:52 
Hi.
 
I just downloaded the wizard and tested it a little bit. It seems great but I can't find a way to navigate pages at designtime. When I have several wizardpages, how can I easily change the active page for modification?
 
br,
kg
GeneralRe: Change wizardpagesmemberGary Noble12 Jun '06 - 22:48 
wizard.gotopage(PageNumber)

GeneralRe: Change wizardpagesmembernumlocked24 Jul '06 - 6:49 
Hmm, I'm having the same problem. It's during design time that I can't look at the page I'm currently designing. I can use that bit of code to change pages programmatically when the thing is running, but I can't physically see the other wizard pages in the IDE. Any ideas?
 
Thanks,
Chris
AnswerRe: Change wizardpagesmemberThe JZ14 Aug '06 - 9:22 
Select the WizardTemplate control, and go to the StartItemIndex property. Enter the number of the page you want to go to and press enter. That wizard page will then be shown.
 
Took me a bit to find this, too. Hope it helps.
AnswerRe: Change wizardpagesmemberRandom@Redgum20 Jun '07 - 14:31 
The Next and Previous buttons are actually active while in design mode, so the easiest way is to simply click on them and they will change through the pages.
 
Enjoy
Random
 
Redgum Technologies
GeneralRe: Change wizardpagesmembersamccabe7 Sep '07 - 7:58 
Thank you SO VERY MUCH for pointing this out!! It's been driving me nuts for a couple of days to try and figure out how to get a particular page to be visible in design mode. This works like a charm. Smile | :)
 
-- Steve Mc

GeneralCrashmembercodepuncher30 May '06 - 16:06 
After using the control for a while, I experienced a crash where the control lost all of the resource information and lost all of the pages and controls I'd added. Have you experienced something like that?
GeneralRe: CrashmemberGary Noble30 May '06 - 22:28 
Hi codepuncher
 
I have not came across this but, can you go into more detail on how this happened.
What caused the crash etc....?
 
kind regards
Gary
GeneralRe: Crashmembercodepuncher2 Jun '06 - 18:35 
Well it turned out that the problem is with the VS2003 editor not the wizard control. The section of code that sets up the form and the resx file got corrupted while editing controls on the wizard pages. Nothing I was editing really stands out at the cause but I did find a couple of newsgroup posts referencing VS corrupting the resx and/or form initialization code at seeminly random intervals. I was able to recover by deleting the resx and editing and correcting the form code outside the editor and then bringing it back in to VS.
 
On another note, I really like the wizard, it makes writing them so mich easier. Thanks.Big Grin | :-D
 

GeneralRe: Crashmembercodepuncher28 Jun '06 - 13:48 
I still think there is something funny going on. I've only had a problem with this control. What happens is that after making a change to a wizard page by adding/removing a control or my changing a property on a control the .vb file is corrupted, the definitions of the wizard pages are lost. Not the hosted controls, just the wizard pages. Only the IDE designer code is lost so I'm guessing there is an exception being raised, being caught and ignored in the control which is preventing the pages designer code from being written. It's pretty consistent now, almost every time I edit the visual properties this happens which means I have to recreate the VB control definitions in a text editor and delete the resx file.
GeneralRe: Crashmemberdefiant7123 Nov '06 - 12:05 
I'm getting this error too... any fix?
GeneralRe: Crashmembersimohack5 Mar '07 - 4:32 
Me too!
GeneralRe: Crashmembertrej12 Apr '07 - 0:57 
AAAH this is a major headache, just lost about 2 days work due to this error. The vb file for my wizard form has been wiped Frown | :(
QuestionHaving trouble using wizardmemberbryndabella30 May '06 - 8:08 
Hello,
 
Please bear with me as I am a novice programmer. I am trying to create a wizard using the GN Wizard Framework, but I am struggling.
 
I have imported the GN Wizard Framework project into my current project and this has allowed me to insert a Wizard Template onto the form etc. I am not sure how much of the code I am required to write. If I want controls on the wizard pages, am I required to write all this in code rather than using the Designer? Secondly I find the Test project a little confusing, there is a region entitled "Windows Form Designer generated code" is this code that is generated by the system or is this code that is written by the programmer?
 
Hoping someone out there can help me along, again I apologise for my limited abilities.
 
bryndabella
AnswerRe: Having trouble using wizardmemberGary Noble30 May '06 - 22:41 

Hi bryndabella
 
A simplistic answer.
When you add the wizard to your project, right click on the wizard and click add new panel or
from the bottom of the property window.
 
When you have added the page all you need to do is add your controls.
The newley created page acts like a tab control you can drag and drop your controls to and from it.(No need to write the code!)Cool | :cool:
 
The "Windows Form Designer generated code" section is automatically populated by the IDE.
When you add a new control to your project the IDE automatically populates that section with the control detail and properties.
 
Hope that answers your question.
 
If you need any more help let me know.
 
Kind regards
Gary
Rose | [Rose]

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 21 Dec 2006
Article Copyright 2006 by Gary Noble
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid