How to set form's Default button to the wizard's Next button

Wizard for Windows Forms Forum

Posted 18 years ago by SR
Avatar
Hi there

I need to use the Wizard control in a mainly non-mouse environment. Please can you advise me when and how to set the wizard's "> Next" button to be the form's default "Enter key" button(AcceptButton?) ? A bit of sample code would be very handy.

I'm also very new to this control and though I'm an experienced VB6 programmer, I'm new to .Net in general : so I'm unclear whether I should use an inherited WizardDialogForm approach, or the wizard control in a form. Sorry if I missed this in the documentation, but any general guidance on 'which approach to use when' would also be greatly appreciated.

Thanks a lot

Scott

Comments (3)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Scott,

You can set the Wizard.FormAcceptButton property to control the default button. It has several different options that will automatically set the default button for you.

You can use either the standalone Wizard control or a Form that inherits from WizardDialogForm. If your Form will only contain the Wizard and not have any other controls within the Form's bounds (other than controls in the Wizard itself of course), it's probably easiest to inherit WizardDialogForm. The WizardDialogForm class exposes a Wizard property that gives you direct access to the embedded Wizard control.


Actipro Software Support

Posted 18 years ago by SR
Avatar
OK, thanks for that, although I was rather hoping for a code snippet by way of explanation.

In the spirit of many of your replies to posts by others I thought I'd load the sample app that you distribute with the product to try this out.

So I have noticed that when I run the sample, when pressing Enter after it has loaded causes the web link to fire. But, by way of example, I want the "Next" button to fire instead.

(I'm using VS.Net 2003 and the VB test app btw.)

So I added the following code to the start of the [Protected Overrides Sub OnSelectionChanged(ByVal e As EventArgs] routine which I thought might do the trick.
If (Me.Wizard.SelectedPage Is startPage) Then
     Me.Wizard.FormAcceptButton = WizardAcceptButtonDefault.Next
End If
Compile and run the program, set breakpoints and check it's executing and then press Enter ... but lo and behold, the web link still fires, not the next button.

What am I doing wrong please?

Please advise

Thanks
Scott
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Scott,

Sorry I didn't include sample code because Wizard.FormAcceptButton is something you can set in the designer and that's all you need to do.

The sample is actually working fine and according to standard Windows behavior. If a LinkLabel or a Button has focus, then the default button will never fire upon an Enter press since the control that has focus will process the Enter as a click instead. This is Windows behavior and actually has nothing to do with our product.

A better test is on our sample's second page. On there, note that if a TextBox has focus, the Next button is highlighted indicating it is the default button. So pressing Enter while in a TextBox will work as you expect and fire the default button. Same thing with controls like ListBox, CheckBox, etc.

Make better sense?


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.