bypassing validation with a button click

B

Bernie Yaeger

I validate - through a delegate - several textbox data when an 'add' button
is clicked. However, when the 'close' button is clicked, I don't want to
validate - I just want to window to close. I know how to override the
validation when the window's 'x' button is clicked with the following:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

If m.Msg = &H10 Then

needvalidating = False

End If

MyBase.WndProc(m)

End Sub

But I can't figure out what to do with a 'close' button on the screen - the
validation begins before any code inside the close.click, so how can I do
this?

Thanks for any help.

Bernie Yaeger
 
C

Cor Ligthert [MVP]

Bernie,

In my idea did we not see you a while. I am glad to see you back.

I don't see why you use a delegate (reference) for this simple problem and
don't call the validating procedure direct by its method, it can not be
threading, because for that you spent almost for sure more time by starting
that threading, than your validating can take time.

However, that is not so important, what I don't see is how that procedure
can be started by pushing at the close x button. You told that it started by
an 'add' button. So it should not be done by a close.
I validate - through a delegate - several textbox data when an 'add'
button is clicked. However, when the 'close' button is clicked, I don't
want to validate - I just want to window to close. I know how to override
the validation when the window's 'x' button is clicked with the following:
Can you give us some information about that?

Cor
 
B

Bernie Yaeger

Hi Cor,

Yes, I've been very busy - thanks for noticing, and nice to hear from you
again.

But the issue is not this - I do use validating events to check the data.
Herfried's article is on the right track, but it too does not work because
when you click the 'close' button, you cannot reset anything - the code runs
after the validating events on the call stack.

Let me know if you have any ideas.

Regards,

Bernie
 
B

Bernie Yaeger

Hi Herfried,

Thanks for your response, but this does not work because when you click the
'close' button, you cannot reset anything - the code runs after the
validating events on the call stack.

Let me know if you have any ideas.

Regards,

Bernie
 
B

Bernie Yaeger

Hi Cor,

I figured it out and you won't believe how easy it was: simply set the
control's 'causes validation' property to false.

Bernie
 
B

Bernie Yaeger

Hi Herfried,

I figured it out and you won't believe how easy it was: simply set the
control's 'causes validation' property to false.

Bernie
 

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