Error provider

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 ?
 
T

tommaso.gastaldi

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
 
S

sebastien1101

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 ?
 
T

tommaso.gastaldi

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) ...
 
S

sebastien1101

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
!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top