Skip to main content

WizardControl.NextClick Event

Fires when the Next button is clicked. Allows you to cancel the operation or navigate to a custom page.

Namespace: DevExpress.XtraWizard

Assembly: DevExpress.XtraWizard.v24.1.dll

NuGet Package: DevExpress.Win

Declaration

public event WizardCommandButtonClickEventHandler NextClick

Event Data

The NextClick event's data class is WizardCommandButtonClickEventArgs. The following properties provide information specific to this event:

Property Description
Handled Gets or sets whether an event was handled.
Page Gets the processed wizard page. Inherited from WizardPageEventArgs.

Remarks

When you click the Next button, the WizardControl automatically navigates to the next wizard page (the WizardControl.Pages collection specifies the navigation order).

You can handle the NextClick event to modify the default navigation route.

To navigate to a custom page, assign this page to the SelectedPage event parameter. You also need to set the WizardCommandButtonClickEventArgs.Handled parameter to true to cancel the default navigation.

The WizardPageEventArgs.Page event parameter allows you to obtain the current page.

To learn more, see Page Events.

Example

The following example handles the WizardControl.NextClick event to change the default navigation route. When a user clicks the Next button in Page1, the WizardControl navigates to Page3.

private void wizardControl1_NextClick(object sender, DevExpress.XtraWizard.WizardCommandButtonClickEventArgs e) {
    if (e.Page.Text == "Page1") {
        WizardControl wc = sender as WizardControl;
        wc.SelectedPage = wc.Pages.OfType<WizardPage>().FirstOrDefault(x => x.Text == "Page3");
        e.Handled = true;
    }
}

Example 2

In the following sample, a Wizard Control has 5 pages:

The code below illustrates how to navigate to a correct page depending on a choice a user makes in the second page.

bool pageSkipped = false;

private void wizardControl1_NextClick(object sender, DevExpress.XtraWizard.WizardCommandButtonClickEventArgs e)
{
    if (e.Page == wizardPage1)
    {
        switch (radioGroup1.EditValue.ToString())
        {
            case ("ToPage2"):
                wizardControl1.SelectedPage = wizardPage2;
                e.Handled = true;
                break;
            case ("ToPage3"):
                wizardControl1.SelectedPage = wizardPage3;
                e.Handled = true;
                pageSkipped = true;
                break;
            case ("ToFinalPage"):
                wizardControl1.SelectedPage = completionWizardPage1;
                e.Handled = true;
                pageSkipped = true;
                break;
        }
    }
}

private void WizardControl1_PrevClick(object sender, DevExpress.XtraWizard.WizardCommandButtonClickEventArgs e)
{
    if (pageSkipped)
    {
        wizardControl1.SelectedPage = wizardPage1;
        pageSkipped = false;
        e.Handled = true;
    }
}
See Also