Click here to Skip to main content
15,888,351 members
Articles / Programming Languages / C#
Article

A Simple Wizard Control for .Net 2.0 with Full Designer Support

Rate me:
Please Sign up or sign in to vote.
4.65/5 (131 votes)
4 Feb 2008CPOL4 min read 539.1K   13.9K   382   178
This is a simple yet powerful wizard framework for .Net 2.0. Just drag and drop and your component is ready for use.
WizardDemo1.png

Introduction

This control allows the creation of a wizard framework in seconds. All you need to do is drag and drop and your wizard is ready for use. This wizard control has full designer support and is highly customizable according to the needs of the user.

Background

I was trying to find a control similar to the wizard in ASP.NET. I learned that it is not available in the .NET Framework, so I decided to make a framework that would allow me to make a wizard in a few simple steps. The wizard control is easy to use - a beginner user should be able to use this control without any problems. The wizard control provides full designer support to users by allowing them to view current program actions.

Using the Library

Step 1: Add a reference to Wizarddemo.dll. This step will add the control automatically to the toolbox of Visual Studio.

Step 2: Drag and drop WizardControl to the form where you want to implement the wizard.

WizardDemo3.png

Once dragged, a wizard is created for the form.

Step 3: Use the designer to customize the designer.

WizardDemo4.png
WizardDemo6.png
WizardDemo7.png
WizardDemo8.png
WizardDemo9.png
WizardDemo10.png
WizardDemo2.png
WizardDemo5.png

Points of Interest

WizardControl

Properties

  • BackButtonEnabled - Defines whether or not the Back button is enabled or disabled.
  • BackButtonText - This can be used to get or set the text of the Back button.
  • BackButtonVisible - Indicates whether the Back button is visible or not.
  • NextButtonEnabled - Defines if the Next button is enabled or disabled.
  • NextButtonText - This can be used to get or set text of the Next button.
  • NextButtonVisible - Indicates whether the Next button is visible or not.
  • CancelButtonEnabled - Defines whether the Cancel button is enabled or disabled.
  • CancelButtonText - This can be used to get or set the text of the Cancel button.
  • CancelButtonVisible - Indicates whether the Cancel button is visible or not.
  • HelpButtonEnabled - Defines whether the the Help button is enabled or disabled.
  • HelpButtonText - This can be used to get or set the text of the Help button.
  • HelpButtonVisible - Indicates whether the Help button is visible or not.
  • FinishButtonText - Text of Finish button.
  • EulaButtonEnabled - Defines if the Eula label is enabled or disabled.
  • EulaButtonText - This can be used to get or set the text of Eula label.
  • EulaButtonVisible - Indicates whether the Eula label is visible or not.

Events

  • BackButtonClick - The Back button is clicked.
  • CancelButtonClick - The Cancel button is clicked.
  • FinishButtonClick - The Finish button is clicked.
  • HelpButtonClick - The Help button is clicked.
  • NextButtonClick - The Next button is clicked.
  • EulaButtonClick - The Eula button is clicked.
  • CurrentStepIndexChanged - Occurs after a current step index is changed.

StartStep

Properties

  • Title - Title text of the step.
  • TitleAppearence - Title appearance of the step.
  • SubTitle - The subtitle text of the step.
  • SubtitleAppearence - The subtitle appearance of step.
  • LeftPair - The back color appearance of the left panel.
  • BindingImage - Image for the step.
  • Icon - Icon displayed in the start step.
  • LeftPanelBackColor - If image is null, left panel back color.

Events

  • BindingImageChanged - Fires when BindingImageChanged of the step is changed.

LicenseStep

Properties

  • Title - Title text of the step.
  • TitleAppearence - Title appearance of the step.
  • SubTitle - Subtitle text of the step.
  • SubtitleAppearence - Subtitle appearance of step.
  • Warning - Warning text.
  • WarningFont - The warning text appearance of the step.
  • BindingImage - Image for the step.
  • HeaderPair - Appearance of header.
  • Accepted - Status of license agreement.
  • AcceptText - Accept text.
  • DeclineText - Accept text.
  • LicenseFile - License file to display.

Events

  • BindingImageChanged - Fires when BindingImageChanged of the step is changed.
  • AgreementChanged - Fires when license agreement of the step is changed.

IntermediateStep

Properties

  • Title - Title text of the step.
  • TitleAppearence - The title text appearance of the step.
  • SubTitle - Subtitle text of the step.
  • SubtitleAppearence - The subtitle appearance of the step.
  • HeaderPair - Appearance of the header.
  • BindingImage - Image for the step.

Events

  • BindingImageChanged - Fires when BindingImageChanged of the step is changed.

FinishStep

Properties

  • BindingImage - Background of the finish step.
  • Pair - Appearance of the body.

Events

  • BindingImageChanged - Fires when BindingImageChanged of the step is changed.

Known Issues

  • During the removal of the wizard control, the step code is not removed from the designer.

History

This is the first release of the wizard. Suggestions are welcome for improving this framework.

First revision: 02/2008

  • Generic designer integrated.
  • Advanced generic collections used.
  • Advanced generic type converters.
  • Very small in size.
  • Serialization support.
  • Reset support.
  • Shadow text support.
  • During the removal of the wizard control, the step code is not removed from the designer: fixed.
  • Problem with binding image fixed; it was not setting to null.
  • New events added.
  • License agreement step added.
  • Finish page updated.
  • Other small issues fixed.

License

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


Written By
Software Developer (Senior)
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
AnswerRe: Whats about an explanation? Pin
Manish Ranjan Kumar16-May-07 20:57
professionalManish Ranjan Kumar16-May-07 20:57 
GeneralRe: Whats about an explanation? Pin
utsav_verma16-May-07 22:49
utsav_verma16-May-07 22:49 
AnswerRe: Whats about an explanation? Pin
Manish Ranjan Kumar17-May-07 0:20
professionalManish Ranjan Kumar17-May-07 0:20 
GeneralVery nice work Pin
Johnny J.14-May-07 21:15
professionalJohnny J.14-May-07 21:15 
AnswerRe: Very nice work Pin
Manish Ranjan Kumar15-May-07 5:48
professionalManish Ranjan Kumar15-May-07 5:48 
GeneralKudos! [modified] Pin
topry11-May-07 9:21
topry11-May-07 9:21 
GeneralTextboxes repositioned during runtime Pin
Jake Stevenson10-May-07 3:22
Jake Stevenson10-May-07 3:22 
GeneralSimilar issue [modified] Pin
Ivan Mitev28-May-07 3:58
Ivan Mitev28-May-07 3:58 
I have a similar issue. It has to do with the Anchor property of controls, put inside a WizardStep. If I set control's (e.g. GroupBox) Anchor = Top, Bottom, Left to a it looks OK in design time, but at runtime it gets stretched way down, below the border of the wizard step. The problem occurs not only with the Top-Bottom anchoring, but with the Right anchor, too.

It seems to me that when the position of the controls is determined, the container control is somehow at its maximum size (not the size I see in the designer).

UPDATE: I debugged the problem with a simple scenario: an intermediate step (middleStep) and of a groupbox in it. Initially the middleStep's size is (0,0). When adding it to the wizardStepsPanel.Controls in WizardControl.DoReLayout() the middleStep size changes to the container's size, but the groupbox expands too much.

Initial:
demoWizard.Size {Width = 524 Height = 394}
middleStep.Size {Width = 0 Height = 0}
groupBox1.Size {Width = 50 Height = 100}

After DoReLayout():
demoWizard.Size {Width = 524 Height = 394}
middleStep.Size {Width = 524 Height = 354}
groupBox1.Size {Width = 574 Height = 454}

It is easy to notice that final groupBox1.Size = initial groupBox1.Size + middleStep.Size.

A quick workaround is to set the initial wizard step size, without affecting the controls in it. We can add and call the following method: ResizeProperlyAllWizardSteps() just after the wizard control is initialized:

     <br />
<br />
        public void ResizeProperlyAllWizardSteps()<br />
        {<br />
            Size size = wizardStepsPanel.Size;<br />
            foreach(WizardStep step in wizardStepCollection)<br />
            {<br />
                ResizeWizardStepWithoutAffectingControls(step, size);<br />
            }<br />
        }<br />
   <br />
        private static void ResizePageWithoutAffectingControls(WizardStep step, Size size)<br />
        {<br />
            if(step.Size == size)<br />
                return;<br />
<br />
            Control[] controls = new Control[step.Controls.Count];<br />
            step.Controls.CopyTo(controls, 0);<br />
<br />
            step.Controls.Clear();<br />
<br />
            step.Size = size;<br />
<br />
            step.Controls.AddRange(controls);<br />
        }



NOTE: Unfortunately at design time sometimes the controls' size and location get changed. I suppose that a similar fix can be applied, but don't have the time to investigate.

-- modified at 4:14 Tuesday 29th May, 2007


-- modified at 6:36 Tuesday 29th May, 2007


-- modified at 12:24 Tuesday 29th May, 2007

Ivan Mitev

GeneralRe: Similar issue Pin
ken.wootton8-Jun-07 11:46
ken.wootton8-Jun-07 11:46 
GeneralRe: Similar issue Pin
Ivan Mitev24-Sep-07 1:21
Ivan Mitev24-Sep-07 1:21 
GeneralRe: Similar issue Pin
ken.wootton24-Sep-07 3:09
ken.wootton24-Sep-07 3:09 
GeneralRe: Similar issue Pin
Ivan Mitev24-Sep-07 8:20
Ivan Mitev24-Sep-07 8:20 
AnswerEasier Solution Pin
gellin21-Aug-08 2:35
gellin21-Aug-08 2:35 
QuestionLicense Pin
ccellar9-May-07 7:55
ccellar9-May-07 7:55 
AnswerRe: License Pin
Manish Ranjan Kumar9-May-07 20:59
professionalManish Ranjan Kumar9-May-07 20:59 
QuestionRe: License Pin
stuartprescott26-Jun-07 23:06
stuartprescott26-Jun-07 23:06 
Generalvery good Pin
k_hammami20058-May-07 23:11
k_hammami20058-May-07 23:11 
QuestionButton sizes, positions and text alignments Pin
Tschoeni8-May-07 22:34
Tschoeni8-May-07 22:34 
AnswerRe: Button sizes, positions and text alignments Pin
OlliFromTor11-May-07 5:00
OlliFromTor11-May-07 5:00 
QuestionRe: Button sizes, positions and text alignments Pin
Tschoeni13-May-07 20:45
Tschoeni13-May-07 20:45 
AnswerRe: Button sizes, positions and text alignments Pin
OlliFromTor14-May-07 5:37
OlliFromTor14-May-07 5:37 
GeneralRe: Button sizes, positions and text alignments Pin
Tschoeni14-May-07 21:50
Tschoeni14-May-07 21:50 
AnswerRe: Button sizes, positions and text alignments [modified] Pin
OlliFromTor15-May-07 4:33
OlliFromTor15-May-07 4:33 
GeneralRe: Button sizes, positions and text alignments Pin
Tschoeni16-May-07 1:25
Tschoeni16-May-07 1:25 
GeneralRe: Button sizes, positions and text alignments Pin
OlliFromTor16-May-07 4:03
OlliFromTor16-May-07 4:03 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.