Validating form controls

Wizard for Windows Forms Forum

Posted 14 years ago by vin
Version: 3.0.0143
Avatar
Hi,

I am new to VB and to wizards. I am trying to create a multi page wizard (about 15 pages) with over 70 questions and controls (labels, textboxes, radio buttons, check boxes, drop down boxes, custom end buttons). I tried 2 vendor solutions (fxware and kellermansoftware) before trying Actipro. I pretty much get things working in the other 2 solutions, but I cannot get the final result I am looking for and hence am trying my luck with Actipro.

1. I would like Next button (or Back) to be greyed out if any controls are not filled out on that page (could be radio button, textbox, checkbox)

2. I would like a double check question on cancel and finish e.g. are you sure you want to cancel - you will loose data if not completing all pages...

3. On the final wizard page I would like some custom buttons e.g. save all inputs to csv file (I have this working in other wizard tools), insert values into Access 2007, insert summary report into Word 2007, insert summary into Word and include averages from Access 2007 query.

Can this be achieved? At the moment, I am stuck on point 1 above how to validate controls on a page and if all questions from page 1 are answered, then user can click next, then repeat of validation on page 2 and so on...

I saw sample code:

Private Sub validatingTextBox_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles validatingTextBox.Validating
If (Me.Wizard.SelectedPage Is dataCollectionPage) And (validatingTextBox.Text.Length = 0) Then
'User has not entered a description, prompt with error provider
errorProvider.SetError(validatingTextBox, "Please provide a description.")
e.Cancel = True
Else
'Cancel any outstanding error provider
errorProvider.SetError(validatingTextBox, Nothing)
End If
End Sub

BUT how do I modify this to perform validation on all my controls on each seperate page?

Thanks in advance

Comments (1)

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

1) I'm not sure if the button would gray out automatically however when the Next button is clicked, the WizardPage.Validate() method is called. The method is defined on the base ContainerControl class and if it returns false, you can't move to the next page. So that code should trigger validation on all contained child controls. Each control typically needs a Validating event handler or some other WinForms way of performing validation.

Alternatively you could attach to various events of each control and manually set whether the Next button should be enabled or not.

2) There are Wizard.CancelButtonClick and FinishButtonClick events that fire. You can show messageboxes from there. Just be sure to set the Wizard.CancelButtonDialogResult and FinishButtonDialogResult properties to DialogResult.None to prevent the Form from auto-closing when those buttons are clicked. Instead your event handlers should close the Form if the user confirms your messagebox prompt.

3) If you mean you want the buttons to be in the bottom row area, then you could add the buttons at the same level as the Wizard within its parent Form. Then just arrange them where you want them on top of the Wizard and hide them until you reach a finish page. You can use the Wizard.SelectionChanged event to know when page changes occur.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.