How to ignore data validation on Form closing

T

Tom

I have written a validatedTextBox class which inherits
from textBox. I've added code which validates the input
text using the onValidation event.

The problem I have is that when I have input invalid data
and then click on the x in the upper right corner of the
form to close the form or when I click on a Cancel button
on the form I would like to not do the validation in that
case. I have not found any event that happens when
closing the window or clicking the Cancel button that
happens before the onValidation event.

Help please. Thanks
 
B

Bernie Yaeger

Hey Rulin,

Excellent code - I've been looking for this for some time! Tx
Bernie Yaeger

Rulin Hong said:
Add following code in winform:

Private NeedValidting As Boolean = True
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
 
T

Tom

Thank you very much for your answer. I'd really
appreciate it if you could tell me a little bit to help me
understand how it works. The first part is obvious, but I
don't know when WndProc gets called or what the possible
values of m.Msg are and what they mean.
I used the debugger and set a break on the line
NeedValidting=false. It never got executed as I nagivated
my form.
I then set the break on the line: If m.Msg = &H10
Then and it got executed many many times.

Specific questions:
Is this (overridden) version WndProc called just for my
valididatedTextBox objects, or for all objects on the form?
Where can I find the meaning of the values m.Msg takes?
Where does WndProc fit in to the overall scheme of event
processing in windows?

Another more general question. I often use the help in
Visual Studio to find out what a class or property does.
(for example searching for WndProc.) All too often the VS
help just gives the arguments to use in the call or the
type of the property, but doesn't tell what it really does
or give the overall context of how that class is used. Is
there a better source of documentation that I could be
using? I am a scientist with 30 years of programming
experience, but am completely new at doing windows
interfaces and fairly new at OOP. Finding the right
classes to do something has been quite difficult and any
pointers you can give me about how to find information
would be greatly appreciated. Note that I have read of
couple of books on visual Basic and written the sample
programs already. Its just that everytime I try to do
something a little different that I don't know how to find
the information about the classes to use.

Thank you very much.
Tom
-----Original Message-----
Add following code in winform:

Private NeedValidting As Boolean = True
Private Sub TextBox1_Validating(ByVal sender As
Object, ByVal e As System.ComponentModel.CancelEventArgs)
Handles TextBox1.Validating
 

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