views:

952

answers:

3

I have been asked to build a custom wizard control in VB.NET for a windows forms project. It has been made very clear to me that I am not "allowed" to utilize existing wizard controls on the internet due to some obscure logic surrounding copyrights. It has also been made clear to me that we are not "allowed" to use usercontrols in the software.

Does anyone have an idea where I should start?

+1  A: 

You can have a bunch of panels and as you move through the wizard you can show or hide the proper panel. The ones like this I have seen are implemented as a state machine more or less. You move between states and set up the panel and do the actions for that stat in a gonext function. Hope that helps.

Erin
+1  A: 

At my job we implemented a wizard using a panel for each step of the wizard. To facilitate working with the panels, we reduce the size of each panel to a small square and put them side to side in the containing control so when we want to edit a panel, we click on the appropriate square, and put the dock property to fill. When we're done, we put back the dock property to none, and the control goes back to its small square dimensions.

Programmatically, you can do something similar to show the good panel for the current step. When the "Next" button is clicked, hide and undock the previous panel, then show and dock the current panel.

Meta-Knight
+1  A: 

A TabControl is a very convenient control in the designer. Changing tab pages at runtime is easy too, just set the SelectedIndex or SelectedTab property. You just need to get rid of the tabs. Luckily, that's easy. Add a new class to your project and paste the code shown below. Build. Drop the new control from the top of the toolbox onto your form.

Public Class WizardPages
    Inherits TabControl
    Protected Overrides Sub WndProc(ByRef m As Message)
        '--- Hide tabs by trapping the TCM_ADJUSTRECT message
        If m.Msg = &H1328 AndAlso Not DesignMode Then
            m.Result = CType(1, IntPtr)
        Else
            MyBase.WndProc(m)
        End If
    End Sub
End Class
Hans Passant