Completed
Last Updated: 03 Apr 2020 11:08 by ADMIN
ADMIN
Dimitar
Created on: 29 Oct 2013 04:05
Category: Wizard
Type: Bug Report
0
FIX. RadWizard - the AcceptButton property of the form does not work with the wizard buttons.
To reproduce:
- Add RadWizard to a form.
- Set the AcceptButton property like this: this.AcceptButton = this.radWizard1.NextButton;
- You will notice that nothing happens when the enter key is pressed. 

Workaround: 
- Use the following PreviewKeyDown event handler: 
void radWizard1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Enter) { this.radWizard1.NextButton.PerformClick(); } }
2 comments
ADMIN
Dess | Tech Support Engineer, Sr.
Posted on: 03 Apr 2020 11:08
Hello, Simon,

Following the provided information, I was able to observe the error you are facing. I would like to note that it is caused by the fact that in the RadWizard.Finish event handler the form is closed programmatically. After that, RadWizard handles the Enter key in its ProcessDialogKey it calls the AcceptButton.PerformClick method while the form is already closed. It is expected in this case to obtain such a behavior.

If I understand your requirement correctly, you need to close the form when the Finish button is clicked via the Enter key. The appropriate way to handle this case is to change the AcceptButton when you navigate to the last page. Please refer to the following help article: 
    Sub New()

        InitializeComponent()

        Me.AcceptButton = Me.RadWizard1.NextButton

        AddHandler Me.RadWizard1.Cancel, AddressOf radWizard1_Cancel
        AddHandler RadWizard1.Finish, AddressOf radWizard1_Finish
        AddHandler Me.RadWizard1.SelectedPageChanged, AddressOf RadWizard_SelectedPageChanged
    End Sub

    Private Sub RadWizard_SelectedPageChanged(sender As Object, e As SelectedPageChangedEventArgs)
        If e.SelectedPage.Name = Me.WizardCompletionPage1.Name Then
            Me.AcceptButton = Me.RadWizard1.FinishButton
        Else
            Me.AcceptButton = Me.RadWizard1.NextButton
        End If
    End Sub
    Private Sub radWizard1_Cancel(ByVal sender As Object, ByVal e As EventArgs)
        Me.Close()
    End Sub
    Private Sub radWizard1_Finish(ByVal sender As Object, ByVal e As EventArgs)
        Me.Close()
    End Sub
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
simon
Posted on: 28 Mar 2020 14:54

When I extend this logic to include the Finish button I get an error when I select Enter to activate the Finish button PerformClick event

 This is the error:

Object reference not set to an instance of an object.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.WinControls.UI.RadWizard.ProcessDialogKey(Keys keyData)

 

This is the code I used :

Private Sub FormWizard_Load(sender As Object, e As EventArgs) Handles Me.Load
        AddHandler Me.RadWizard1.Cancel, AddressOf radWizard1_Cancel
        AddHandler RadWizard1.Finish, AddressOf radWizard1_Finish
       
    End Sub


    Private Sub RadWizard1_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) Handles RadWizard1.PreviewKeyDown

        If e.KeyCode = Keys.Escape Then
            Me.Close()
        Else

            If Me.RadWizard1.FinishButton.Visibility = Telerik.WinControls.ElementVisibility.Visible Then
                If e.KeyCode = Keys.Enter Then Me.RadWizard1.FinishButton.PerformClick()
            Else
                If e.KeyCode = Keys.Enter Then Me.RadWizard1.NextButton.PerformClick()
            End If
        End If

    End Sub

    Private Sub radWizard1_Cancel(ByVal sender As Object, ByVal e As EventArgs)
        Me.Close()
    End Sub

    Private Sub radWizard1_Finish(ByVal sender As Object, ByVal e As EventArgs)
        Me.Close()
    End Sub