Error provider

  • Thread starter Thread starter sebastien1101
  • Start date Start date
S

sebastien1101

I have an errorprovider in a tabControl

i use this to validating all field required
Private Sub Champs_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles txtSociete.Validating,
txtAdresse.Validating, txtCodePostal.Validating, txtVille.Validating
Dim monControl As TextBox = CType(sender, TextBox)
If (monControl.Text.Trim().Length = 0) Then
ErrorProvider1.SetError(monControl, "Merci de renseigner ce
champ.")
Else
ErrorProvider1.SetError(monControl, "")
End If

End Sub


===>> my problem : When i click the submit button... (and my requiered
fields are empty) nothing stop me...!!!

Why ?
 
may be hard to stop you :) Let's see if we can at least stop the exit
from the edit state with:

e.Cancel = True


.....
Else
ErrorProvider1.SetError(monControl, "")
End If
 
oh thx but it's only work for my first control Handles
txtSociete.Validating

all the other txtAdresse.Validating, txtCodePostal.Validating,
txtVille.Validating doesn't work

i must have several validating sub ??? for working ?
 
it depends on the effect you want to achieve. If you want to let the
user free to do anything and check only at the end, you will do the
checking at the "Closing" event (assuming we are talking of a kind of
dialog form) ...
 
i have a form and some field in a form

when the user click submit i want to stop it if the requiered field are
empty

i think errorprovider with validating could do that ? but it's working
only if the user leave all requiered field with empty to have a warning
!!!
 
Back
Top