Click here to Skip to main content
13,347,671 members (52,791 online)
Click here to Skip to main content
Add your own
alternative version


26 bookmarked
Posted 21 Dec 2002

Another wizard for .NET using tab control

, 21 Dec 2002
Rate this:
Please Sign up or sign in to vote.
Another wizard for .NET using tab control
<!-- Download Links --> <!-- Article image -->

Sample Image - WizardForm.jpg

<!-- Add the rest of your HTML here -->


Some month that I have started to develop with .NET framework and C#. Used to MFC, I was very disappointed to not found a class to make a wizard. I’ve checked the web, and found the wizard framework of James T. Johnson. But, in fact, I found it a little complicated to use and design, so I’ve developed my own. The idea, is to ease the design of the wizard and re-use MFC concept.

With MFC, the creation of a wizard was the same process than create tab control and tab page. So, I’ve decided to reuse the Visual Studio .NET wizard to create Tab control, and work around.

The final result is a dialog, with an empty tab control that must be inherited. At design time, the developer create tab page and fill them with the control that he wants. At run time, the dialog act as a wizard, hiding the tab control.

Design of a simple wizard

Inheritance of dialog wizard

Use the “Add inherited form” wizard in Visual, and select the WizardForm in the inheritance picker dialog.


You have the following form in your project:

The tab control is empty, but you see the 4 essential buttons : “Cancel”, ”Back”, “Next” and “Finish”.

Creating pages

Create the pages of the wizard, as you create page for a tab control. Take in mind that the order of the page will be the order of the page in the wizard. For each tab page, set the text to the text that describe the step of the wizard. This text will appear in the title of the wizard at run time.


Implement ActivatePage method

The ActivatePage method is called automatically before a page is displayed. This method have the zero based number of the displayed page as parameter. The developer must implement this method to do all the initialization task of a page. This method is called only one time per page.

Another method, UnActivatePage is used to deactivate a page, to allow the ActivatePage will be called again if the user go back and forward.

protected override void ActivatePage(int piPageNumber) 
  switch (piPageNumber)
    case 1: 
      DataTable oTable = new DataTable();

      // Do some stuff to init the page

Implement ValidatePage method

The ValidatePage method is called when the user use the “Next” or “Finish” button. The number of the current page is in the integer parameter. This method must return true if the page is validated. If this method return false, the “next” or “Finish” button doesn’t do anything, until the page is validated.

Run wizard

Simply use the ShowDialog method to show the wizard. It would start by the first tab page. Clicking on the “Finish” button will end the wizard, but would use the ActivatePage and ValidatePage for each remaining page.

Since the Wizard is inherited, you can freely customize the base dialog, button and tab control. Just keep in mind that the tab control is hidden, and the underlying tab page, resized to fill the space used by the tab control.

You can also add button anywhere on the drawing surface of the dialog to your own purpose. 

protected override bool ValidatePage(int piPageNumber) 
  switch (piPageNumber) 
    case 0: 
      if (textBox1.Text != string.Empty & textBox2.Text != string.Empty) 
        return true; 
      MessageBox.Show(this, "Complete data first"); 
      return false; 
  return true; 

Other methods used


This method is used, when the user use the “Back” button, to deactivate a page, so the ActivatePage be called again. piPageNumber parameter is the number of the page that must be deactivated.


This method is called to allow or disallow the back button in the wizard. The default behaviour is back enabled.


This method can be overloaded. This method increment the number of the displayed page. The default, is an increment by 1. Overload this method if you want to jump over pages.


This method as the same function as ForwardOffset , but decrement the displayed page by 1 per default. Overload this method to have a different behaviour. 


December 2002

  • Initial posting


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Software Developer (Senior)
France (Metropolitan) France (Metropolitan)
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionLicense Pin
Postremus1-Jan-13 5:10
memberPostremus1-Jan-13 5:10 
AnswerRe: License Pin
nimbus3d4-Jan-13 23:04
membernimbus3d4-Jan-13 23:04 
GeneralResize Warning .net 2.0 Pin
Clermond25-Dec-05 5:53
memberClermond25-Dec-05 5:53 
GeneralFranework to Wizard from VBPJ Pin
tengtium7-Mar-05 2:53
membertengtium7-Mar-05 2:53 
GeneralCreating Tab Index Pin
Anonymous3-Dec-04 21:38
sussAnonymous3-Dec-04 21:38 
GeneralResize the wizard Pin
Tsjaar26-Oct-04 3:45
memberTsjaar26-Oct-04 3:45 
GeneralRe: Resize the wizard Pin
miqel8-Feb-11 1:30
membermiqel8-Feb-11 1:30 
GeneralTab control Pin
Deepkiss24-May-03 2:58
memberDeepkiss24-May-03 2:58 
GeneralTab control Pin
Deepkiss24-May-03 2:49
memberDeepkiss24-May-03 2:49 
GeneralRe: Tab control Pin
nimbus3d24-May-03 3:23
membernimbus3d24-May-03 3:23 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 22 Dec 2002
Article Copyright 2002 by nimbus3d
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid