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 ?

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.130516.1 | Last Updated 21 Dec 2006
Article Copyright 2006 by Gary Noble
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid