ErrorProvider problem

A

Alvaro Lamas

I have a problem with the ErrorProvider with a mdi interface, I have a MDI
form which opens a child form, that child form uses the errorprovider to
show the problems with the data entry. The problem happens when I use the
show method of the child form it will try to validate the first field and
since it need to not empty and its just opening for the first time it fails
and the errorprovider shows an error icon, something that I obviously dont
want since the user hasnt done anything wrong yet. any Ideas?

Thanks in advanced.
Alvaro
 
C

Cor Ligthert

Alvaro,

Did you use the "getfocus" event instead of the "validating" event in the
MDI form. It sounds like that.

However I think you need to show some "sample" code how you did it.

I hope this helps

Cor
 
A

Alvaro Lamas

Well I did use validating here is the code where I create the child form:

Dim FormInstance As MyForm

FormInstance = New MyForm(ks_FormType.ks_Adding)

FormInstance.MdiParent = Me

FormInstance.Show()

FormInstance = Nothing

Here is the code where I use the error provider to validate:

Private Sub Name_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles Name.Validating

If IsNothing(Me.Name.Text) Or (Me.Name.Text = "") Then

Me.epPuesto.SetError(Me.txtNombre, "ERROR MESSAGE")

e.Cancel = True

Else

Me.epPuesto.SetError(Me.txtNombre, "")

e.Cancel = False

End If

End Sub

I have basically the same code in all the rest of the controls in that form.
One thing I did notice is that in a dialog that I call upon with the same
validation scheme doesn't produce the same error and the only diference that
I can see is that said dialog isn't a child of the main program form.

Alvaro, again thanks in advanced.
 
C

Cor Ligthert

Alvaro,

It seems to me that MyForm is not a standard form, however an inherited
form. So answering withouth to know that, and as well what you are doing
with that, makes it in my opinion not simple.

Better to say what does that member in MyForm?

Cor
 
A

Alvaro Lamas

It is a standard form, it just has a modified constructor to know who is
calling it and for what reason. the wierd thing is that another form that I
open that I am not making a child of the mdi parent and that I call upon
using the showdialog method instead of the show method, in this case the
problem doesnt arrise.
 

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