windowsforms-devexpress-dot-xtrawizard-dot-wizardcontrol-062b6114.md
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.v25.2.dll
NuGet Package : DevExpress.Win
public event WizardCommandButtonClickEventHandler NextClick
Public Event NextClick As WizardCommandButtonClickEventHandler
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. |
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.
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;
}
}
Private Sub WizardControl1_NextClick(sender As Object, e As DevExpress.XtraWizard.WizardCommandButtonClickEventArgs) _
Handles WizardControl1.NextClick
If e.Page.Text = "Page1" Then
Dim wc As WizardControl = TryCast(sender, WizardControl)
wc.SelectedPage = wc.Pages.OfType(Of WizardPage)().FirstOrDefault(Function(x) x.Text = "Page3")
e.Handled = True
End If
End Sub
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;
}
}
Private pageSkipped As Boolean = False
Private Sub wizardControl1_NextClick(ByVal sender As Object, ByVal e As DevExpress.XtraWizard.WizardCommandButtonClickEventArgs)
If e.Page.Name = WizardPage1.Name Then
Select Case radioGroup1.EditValue.ToString()
Case ("ToPage2")
wizardControl1.SelectedPage = wizardPage2
e.Handled = True
Case ("ToPage3")
wizardControl1.SelectedPage = wizardPage3
e.Handled = True
pageSkipped = True
Case ("ToFinalPage")
wizardControl1.SelectedPage = completionWizardPage1
e.Handled = True
pageSkipped = True
End Select
End If
End Sub
Private Sub WizardControl1_PrevClick(ByVal sender As Object, ByVal e As DevExpress.XtraWizard.WizardCommandButtonClickEventArgs)
If pageSkipped Then
wizardControl1.SelectedPage = wizardPage1
pageSkipped = False
e.Handled = True
End If
End Sub
See Also