error provider
-
Hi everyone. Hoping for some clarification how the error provider and the "validating" event works on a form, because what I am experiencing doesn't seem very user friendly for the end user. In a nutshell, once the control FAILS my conditions in the "validating" event and I issue the e.cancel command, focus returns to the failed control and I cannot move the focus until the control has a valid entry. Why is this bad ? For example, consider a textbox that accepts a file system directory path, and a browse button next to it. I want the advanced users to be able to type (using autocomplete) the path and basic users to be able to use the browse button. However once the textbox has the focus, any attempts to click on the browse button fail as the focus cannot move from the textbox that just failed validation. Now I have read a lot of articles, and it appears the error provider doesn't normally exhibit this behaviour. Am I right ?? If it is not normal, any ideas what might cause this ?? - I have a form with a tabcontrol that has several pages - I have an error provider on the form - All bound controls reference the same bindingsource - initially the error provider had a datasource of the bindingsource. I removed it and still nothing. Here is one of the pieces of code: Private Sub txtClientBaseFilePath_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtClientBaseFilePath.Validating Dim IsError As Boolean = False 'check if the string is not null using the basic textbox validation If IsTextBoxEmpty(txtClientBaseFilePath, strErrorPathNotSpecified & strErrorPath) = True Then IsError = True Else 'check if the patch exists. if not exist then offer to create the path Try If My.Computer.FileSystem.DirectoryExists(txtClientBaseFilePath.Text) = False Then If MessageBox.Show("Directory does not exist. " & vbCrLf & vbCrLf & "Would you like to create the directory?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then My.Computer.FileSystem.CreateDirectory(txtClientBaseFilePath.Text) SetStatusLabel("Directory '" & txtClientBaseFilePath.Text & "' created successfully", False) Else Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathMustExist)
-
Hi everyone. Hoping for some clarification how the error provider and the "validating" event works on a form, because what I am experiencing doesn't seem very user friendly for the end user. In a nutshell, once the control FAILS my conditions in the "validating" event and I issue the e.cancel command, focus returns to the failed control and I cannot move the focus until the control has a valid entry. Why is this bad ? For example, consider a textbox that accepts a file system directory path, and a browse button next to it. I want the advanced users to be able to type (using autocomplete) the path and basic users to be able to use the browse button. However once the textbox has the focus, any attempts to click on the browse button fail as the focus cannot move from the textbox that just failed validation. Now I have read a lot of articles, and it appears the error provider doesn't normally exhibit this behaviour. Am I right ?? If it is not normal, any ideas what might cause this ?? - I have a form with a tabcontrol that has several pages - I have an error provider on the form - All bound controls reference the same bindingsource - initially the error provider had a datasource of the bindingsource. I removed it and still nothing. Here is one of the pieces of code: Private Sub txtClientBaseFilePath_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtClientBaseFilePath.Validating Dim IsError As Boolean = False 'check if the string is not null using the basic textbox validation If IsTextBoxEmpty(txtClientBaseFilePath, strErrorPathNotSpecified & strErrorPath) = True Then IsError = True Else 'check if the patch exists. if not exist then offer to create the path Try If My.Computer.FileSystem.DirectoryExists(txtClientBaseFilePath.Text) = False Then If MessageBox.Show("Directory does not exist. " & vbCrLf & vbCrLf & "Would you like to create the directory?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then My.Computer.FileSystem.CreateDirectory(txtClientBaseFilePath.Text) SetStatusLabel("Directory '" & txtClientBaseFilePath.Text & "' created successfully", False) Else Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathMustExist)
Thinking about it I guess it is behaving as expected. ie: when leaving the control the validating routine runs and when it fails the action to move elsewhere is aborted through the e.cancel. So with this in mind I have moved the code to different events such as "TextChanged" and "Leave" BUT for some reason the errorprovider only displays on some occasions rather than all. Typically on the first time I enter an invalid value (such as blank ""), the errorprovider doesn't display but if I create the same error it displays. This validation stuff is driving me Nuts !!!! What do you guys normally do to validate a whole bunch of controls on a page ? I would have thought validating field by field was more user friendly than waiting til the end and doing it, but as described in my example sometimes it isn't practical to force a user to stay on the control.