Hi,
thanks, very nice and useful wizard. I just have a scenario, when I connect to a USB device in the second page. The problem was, where to put a code to connect to the device? When I put it to the VisibleChange event, or SetActive event, or whereever possible, the message box has popped up when the first page was visible yet. So, I have changed WizardSheet.cs a little bit:
private void SetActivePage(WizardPage newPage)
{
WizardPage oldActivePage = _activePage;
// If this page isn't in the Controls collection, add it.
// This is what causes the Load event, so we defer
// it as late as possible.
if (!pagePanel.Controls.Contains(newPage))
pagePanel.Controls.Add(newPage);
_activePage = newPage;
CancelEventArgs e = new CancelEventArgs();
newPage.OnSetActive(e);
if (e.Cancel)
{
_activePage = oldActivePage;
}
// Hide all of the other pages.
foreach (WizardPage page in _pages)
{
if (page != _activePage)
page.Visible = false;
}
// Show active this page.
_activePage.Visible = true;
}
Now, I can put my code into
private void MyWizardPage_VisibleChanged(object sender, EventArgs e)
{
if (this.Visible == true)
{
// my code, MessageBox in case of problems
}
}
Change Visible after setActive
private void SetActivePage(WizardPage newPage) { WizardPage oldActivePage = _activePage; // If this page isn't in the Controls collection, add it. // This is what causes the Load event, so we defer // it as late as possible. if (!pagePanel.Controls.Contains(newPage)) pagePanel.Controls.Add(newPage); _activePage = newPage; CancelEventArgs e = new CancelEventArgs(); newPage.OnSetActive(e); if (e.Cancel) { _activePage = oldActivePage; } // Hide all of the other pages. foreach (WizardPage page in _pages) { if (page != _activePage) page.Visible = false; } // Show active this page. _activePage.Visible = true; }Now, I can put my code intoprivate void MyWizardPage_VisibleChanged(object sender, EventArgs e) { if (this.Visible == true) { // my code, MessageBox in case of problems } }