Skip to content

Documentation

David Hall edited this page Jul 2, 2017 · 1 revision

On this page:

Initializing pages

If the page needs be initialized based on conditions present when the page is viewed, use the Initialize event.

public MyWizard()
{
   InitializeComponent();
   middlePage.Initialize += middlePage_Initialize;
}

private void middlePage_Initialize(object sender, AeroWizard.WizardPageInitEventArgs e)
{
   if (!System.IO.File.Exists("myfile.txt"))
      checkBox1.Enabled = false;
   else
      checkBox1.Checked = System.IO.File.ReadAllText("myfile.txt") == "true";
}

Handling page commits

This is the ideal way to determine when a page is completed and the user has elected to move forward. While the SelectedPageChanged event will also tell you that a new page has been loaded, the Commit event tells you that the user has completed work on a page and has chosen to move forward and allows you to prohibit that advance.

public MyWizard()
{
   InitializeComponent();
   dataPage.Commit += dataPage_Commit;
}

void dataPage_Commit(object sender, AeroWizard.WizardPageConfirmEventArgs e)
{
   // If the user hasn't provided a sufficiently long zip code, don't allow the commit
   if (zipTextBox.Text.Length < 5)
      e.Cancel = true;
   else
   {
      // Based on user selection for delivery option, go to appropriate page
      if (nextDayRadioButton.Checked)
         this.NextPage = nextDayMailPage;
      else
         this.NextPage = stdMailPage;
   }
}

Handling page rollbacks

If the user clicks the back button, the Rollback event is fired and can be handled to undo any actions that may have occurred on initialization or from user interactions with the page.

public MyWizard()
{
   InitializeComponent();
   middlePage.Rollback += middlePage_Rollback;
}

private void middlePage_Rollback(object sender, AeroWizard.WizardPageConfirmEventArgs e)
{
   File.Delete(filename);
}

Navigating

You can programmatically navigate to pages outside of the regular sequence at both run-time and design-time.

Run-time

private void button1_Click(object sender, EventArgs e)
{
   switch (itemText)
   {
      case "First Page":
         RestartPages();
         break;
      case "Previous Page":
         PreviousPage();
         break;
      case "Next Page":
         NextPage();
         break;
      case "Specific Page":
         NextPage(wizardPage10);
         break;
   }
}

Design-time

Navigation changes are handled through properties on a specific WizardPage.

  • To allow or disallow movement using the next, back or cancel buttons, use the AllowNext, AllowBack, and AllowCancel properties.
  • To hide the next, back or cancel buttons, set the ShowNext, ShowBack, and ShowCancel properties to false.
  • To indicate that a page is the last page in the sequence and should display the Finish text instead of the Next text on the Next/Finish button, use the IsFinishPage property.
  • To indicate a specific page that should be used when the user clicks the Next button or when the NextPage() method is called, use the NextPage property. This is used to override the default behavior of going to the next page in the sequence defined within the Pages collection.
  • To effectively hide a page from the normal flow of the Pages collection, set the Supress property to true.