Wizard Dialog Example for WinForms

Nevron NOV UserInterface for WinForms ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WinForms UserInterface examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

Wizard Dialog Example for WinForms Description

This example demonstrates how to use the NWizardDialog.

The NWizardDialog dialog consists of pages, each having an optional header and content.

The user is able to navigate through the pages via the Back and Next button.

When the user reaches the last page, the Finish button is enabled.

The NWizardDialog allows for many modifications including wizards with multiple paths, like the wizard displaed by the 'Show Dynamic Wizzard' button.


Wizard Dialog Example

C# Wizard Dialog Example Code for Nevron UserInterface for WinForms
Language: C#

using Nevron.Nov;
using Nevron.Nov.DataStructures;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NWizardDialogExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

		#region Example

		public NWidget CreateExampleContent()
		{
			NStackPanel stack = new NStackPanel();
			stack.Padding = new NMargins(10);
			stack.HorizontalPlacement = ENHorizontalPlacement.Left;
			

            NButton showSimpleWizard = new NButton("Show Simple Wizzard...");
			showSimpleWizard.Click += OnShowWizzardClick;
			stack.Add(showSimpleWizard);

            NButton showDynamicWizard = new NButton("Show Dynamic Wizzard...");
            showDynamicWizard.Click += OnShowDynamicWizardClick;
            stack.Add(showDynamicWizard);

            return stack;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
            stack.FillMode = ENStackFillMode.Last;

            // create the events list box
            m_EventsLog = new NExampleEventsLog();
            stack.Add(m_EventsLog);

            return stack;
		}
		public string GetExampleDescription()
		{
			return @"

This example demonstrates how to use the NWizardDialog.

The NWizardDialog dialog consists of pages, each having an optional header and content.

The user is able to navigate through the pages via the Back and Next button.

When the user reaches the last page, the Finish button is enabled.

The NWizardDialog allows for many modifications including wizards with multiple paths, like the wizard displaed by the 'Show Dynamic Wizzard' button.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Top Level Windows", "https://www.nevron.com/docs/openvision/ui-top-level-windows.html"), ("Containers Overview", "https://www.nevron.com/docs/openvision/ui-containers-overview.html"), }; } #endregion #region Implementation #endregion #region Event Handlers private void OnShowWizzardClick(NEventArgs arg) { NWizardDialog dialog = NApplication.CreateTopLevelWindow(); dialog.Title = "Simple Wizzard"; NWizardPage page1 = CreateSimplePage("Page 1", "I am the content of page 1"); NWizardPage page2 = CreateSimplePage("Page 2", "I am the content of page 2"); NWizardPage page3 = CreateSimplePage("Page 3", "I am the content of page 3"); dialog.Initialize(new NWizardPage[] { page1, page2, page3 }); dialog.CurrentPageIndexChanged += (args) => { m_EventsLog.LogEvent("Current Page Index changed to result: " + dialog.Result); }; dialog.Closed += (args) => { if (args.EventPhase != ENEventPhase.AtTarget) return; m_EventsLog.LogEvent("Wizard closed with result: " + dialog.Result); }; dialog.Open(); } private void OnShowDynamicWizardClick(NEventArgs arg) { NWizardDialog dialog = NApplication.CreateTopLevelWindow(); dialog.Title = "Dynamic Wizzard"; // create some simple pages // NOTE: page3 will be the last page in the wizard page collection, so it is naturally final // page 1 and page 2 need to be explicitly marked as final NWizardPage page1 = CreateSimplePage("Choice 1", "I am the content of choice 1"); page1.IsFinal = true; NWizardPage page2 = CreateSimplePage("Choice 2", "I am the content of choice 2"); page2.IsFinal = true; NWizardPage page3 = CreateSimplePage("Choice 3", "I am the content of choice 3"); // create a page from which the user chooses the next page. NRadioButtonGroup selectPathRadio = new NRadioButtonGroup(); NStackPanel stackPanel = new NStackPanel(); selectPathRadio.Content = stackPanel; NRadioButton radio1 = new NRadioButton("Choice 1"); stackPanel.Add(radio1); NRadioButton radio2 = new NRadioButton("Choice 2"); stackPanel.Add(radio2); NRadioButton radio3 = new NRadioButton("Choice 3"); stackPanel.Add(radio3); selectPathRadio.SelectedIndex = 0; NWizardPage choicePage = new NWizardPage("Choice Page"); choicePage.Title = "Choice Page"; choicePage.Content = selectPathRadio; choicePage.GetNextPageIndexDelegate = (theDialog) => { switch (selectPathRadio.SelectedIndex) { case 0: return Array.IndexOf(theDialog.Pages, page1); case 1: return Array.IndexOf(theDialog.Pages, page2); case 2: return Array.IndexOf(theDialog.Pages, page3); default: return -1; } }; dialog.Initialize(new NWizardPage[] { choicePage, page1, page2, page3 }); dialog.CurrentPageIndexChanged += (args) => { m_EventsLog.LogEvent("Current Page Index changed to result: " + dialog.Result); }; dialog.Closed += (args) => { if (args.EventPhase != ENEventPhase.AtTarget) return; m_EventsLog.LogEvent("Wizard closed with result: " + dialog.Result); }; dialog.Open(); } private NWizardPage CreateSimplePage(string title, string content) { NWizardPage page = new NWizardPage(); page.MinSize = new NSize(300, 200); page.Header.Content = new NLabel(title); page.Content = new NLabel(content); page.Title = title; return page; } #endregion #region Fields // Controls private NExampleEventsLog m_EventsLog; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Wizard Dialog Example for WinForms Solution

VB.NET Wizard Dialog Example Code for Nevron UserInterface for WinForms
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Forms
Imports System

Public Class Form1

#Region "Constructors"

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        ' Set form title
        Text = "NOV WinForms - NWizardDialogExample"

        ' Create the NOV example and its controls
        Dim exampleContent As NWidget = CreateExampleContent()
        Dim exampleControls As NWidget = CreateExampleControls()
        If Not exampleControls Is Nothing Then
            exampleControls.PreferredWidth = 300
        End If

        ' Place the example and its controls in a pair box
        Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
        pairBox.FillMode = ENStackFillMode.First
        pairBox.FitMode = ENStackFitMode.First
        pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)

        ' Host the example in the form
        Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
        host.Dock = DockStyle.Fill
        Controls.Add(host)
    End Sub


#End Region

#Region "Example"

        Public Function CreateExampleContent() As NWidget
            Dim stack As NStackPanel = New NStackPanel()
            stack.Padding = New NMargins(10)
            stack.HorizontalPlacement = ENHorizontalPlacement.Left


            Dim showSimpleWizard As NButton = New NButton("Show Simple Wizzard...")
            showSimpleWizard.Click += AddressOf OnShowWizzardClick
            stack.Add(showSimpleWizard)

            Dim showDynamicWizard As NButton = New NButton("Show Dynamic Wizzard...")
            showDynamicWizard.Click += AddressOf OnShowDynamicWizardClick
            stack.Add(showDynamicWizard)

            Return stack
        End Function
        Public Function CreateExampleControls() As NWidget
            Dim stack As NStackPanel = New NStackPanel()
            stack.FillMode = ENStackFillMode.Last

            ' create the events list box
            m_EventsLog = New NExampleEventsLog()
            stack.Add(m_EventsLog)

            Return stack
        End Function
        Public Function GetExampleDescription() As String
            Return "

This example demonstrates how to use the NWizardDialog.

The NWizardDialog dialog consists of pages, each having an optional header and content.

The user is able to navigate through the pages via the Back and Next button.

When the user reaches the last page, the Finish button is enabled.

The NWizardDialog allows for many modifications including wizards with multiple paths, like the wizard displaed by the 'Show Dynamic Wizzard' button.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Top Level Windows", "https://www.nevron.com/docs/openvision/ui-top-level-windows.html"), ("Containers Overview", "https://www.nevron.com/docs/openvision/ui-containers-overview.html")} End Function #End Region #Region "Implementation" #End Region #Region "Event Handlers" Private Sub OnShowWizzardClick(arg As NEventArgs) Dim dialog As NWizardDialog = NApplication.CreateTopLevelWindow(Of NWizardDialog)() dialog.Title = "Simple Wizzard" Dim page1 = CreateSimplePage("Page 1", "I am the content of page 1") Dim page2 = CreateSimplePage("Page 2", "I am the content of page 2") Dim page3 = CreateSimplePage("Page 3", "I am the content of page 3") dialog.Initialize(New NWizardPage() {page1, page2, page3}) dialog.CurrentPageIndexChanged += Sub(args) m_EventsLog.LogEvent("Current Page Index changed to result: " & dialog.Result.ToString()) dialog.Closed += Sub(args) If args.EventPhase IsNot ENEventPhase.AtTarget Then Return m_EventsLog.LogEvent("Wizard closed with result: " & dialog.Result.ToString()) End Sub dialog.Open() End Sub Private Sub OnShowDynamicWizardClick(arg As NEventArgs) Dim dialog As NWizardDialog = NApplication.CreateTopLevelWindow(Of NWizardDialog)() dialog.Title = "Dynamic Wizzard" ' create some simple pages ' NOTE: page3 will be the last page in the wizard page collection, so it is naturally final ' page 1 and page 2 need to be explicitly marked as final Dim page1 = CreateSimplePage("Choice 1", "I am the content of choice 1") page1.IsFinal = True Dim page2 = CreateSimplePage("Choice 2", "I am the content of choice 2") page2.IsFinal = True Dim page3 = CreateSimplePage("Choice 3", "I am the content of choice 3") ' create a page from which the user chooses the next page. Dim selectPathRadio As NRadioButtonGroup = New NRadioButtonGroup() Dim stackPanel As NStackPanel = New NStackPanel() selectPathRadio.Content = stackPanel Dim radio1 As NRadioButton = New NRadioButton("Choice 1") stackPanel.Add(radio1) Dim radio2 As NRadioButton = New NRadioButton("Choice 2") stackPanel.Add(radio2) Dim radio3 As NRadioButton = New NRadioButton("Choice 3") stackPanel.Add(radio3) selectPathRadio.SelectedIndex = 0 Dim choicePage As NWizardPage = New NWizardPage("Choice Page") choicePage.Title = "Choice Page" choicePage.Content = selectPathRadio choicePage.GetNextPageIndexDelegate = Function(theDialog) Select Case selectPathRadio.SelectedIndex Case 0 Return Array.IndexOf(Of NWizardPage)(theDialog.Pages, page1) Case 1 Return Array.IndexOf(Of NWizardPage)(theDialog.Pages, page2) Case 2 Return Array.IndexOf(Of NWizardPage)(theDialog.Pages, page3) Case Else Return -1 End Select End Function dialog.Initialize(New NWizardPage() {choicePage, page1, page2, page3}) dialog.CurrentPageIndexChanged += Sub(args) m_EventsLog.LogEvent("Current Page Index changed to result: " & dialog.Result.ToString()) dialog.Closed += Sub(args) If args.EventPhase IsNot ENEventPhase.AtTarget Then Return m_EventsLog.LogEvent("Wizard closed with result: " & dialog.Result.ToString()) End Sub dialog.Open() End Sub Private Function CreateSimplePage(title As String, content As String) As NWizardPage Dim page As NWizardPage = New NWizardPage() page.MinSize = New NSize(300, 200) page.Header.Content = New NLabel(title) page.Content = New NLabel(content) page.Title = title Return page End Function #End Region #Region "Fields" ' Controls Private m_EventsLog As NExampleEventsLog #End Region #Region "Static Methods" #End Region #Region "Constants" #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Wizard Dialog Example for WinForms Solution

Related Documentation Links