473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to ignore data validation on Form closing

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
Nov 20 '05 #1
2 2759
Hey Rulin,

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

"Rulin Hong" <Ru*******@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
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 If NeedValidting Then
'Do Validating
End If
End Sub

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = &H10 Then
NeedValidting = False
End If
MyBase.WndProc(m)
End Sub

Nov 20 '05 #2
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 If NeedValidting Then
'Do Validating
End If
End Sub

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = &H10 Then
NeedValidting = False
End If
MyBase.WndProc(m)
End Sub
.

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Dynamo | last post by:
Hi The following script was taken from John Coggeshall's (PHP consultant) in his article on Zends site at http://www.zend.com/zend/spotlight/ev12apr.php // Get the email address to validate...
6
by: MickG | last post by:
Hi, I am trying to validate these values, this seems to work fine for the phone number and name but I am trying to get the program to fail to submit and set the focus on the date when 2006 is...
1
by: John | last post by:
My data has 10 accounts. Two forms are opened simultaneously. Form1 is unbound and displays three records: Account Quantity 101 17 104 25 107 ...
2
by: Dnna | last post by:
I have a table which is bound to an Internet Explorer XML data island. I'm using ASP.NET's client-side validators for an input field in the table. The problem is that if the input fields are in...
6
by: RSB | last post by:
Hi I am executing a JavaScript Function for a Button and doing some custom data validation. Now i want to Ignore the Button Click if the Data validation Fails. i am using return(false) in the...
3
by: CJ Taylor | last post by:
Another quesiton, I have a form, with a control on it that has a handler for control.validated event. Now, if that control has focus, and I click the close button the validation event fires.....
22
by: Charles Law | last post by:
Could someone please explain to me, in words of one syllable or less, how I get the Validating event to fire for a form. I have a form with one text box, and two buttons: OK and Cancel. I have...
2
by: cashdeskmac | last post by:
This is regarding VS 2003 Windows forms. I have TextBoxes which use the Validating event when the user shifts focus. When the user closes down the form using the red cross in the top left...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.