473,545 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any Method to Raise a Validating Event to other control?

Hi All,
I am writing a simple win form which contains a button, when user click the
button i want to validate all the other textbox and see if there is anything
goes wrong

may i know how can i trigger the validating event for all text box?

thx and regard,s
Norton
Nov 21 '05 #1
5 9319
How many textboxes & what are you validating against?
Nov 21 '05 #2
Norton,
I got the following tip from "Windows Forms Programming in C#" by Chris
Sells, from Addison Wesley.

Within your "Accept" button click handler (the "save" button) process each
control that CausesValidatio n to ensure that they are all valid...

Something like:

For Each control As control In Me.Controls
If control.CausesV alidation Then
control.Focus()
If Not Me.Validate() Then
Me.DialogResult = DialogResult.No ne
Exit For
End If
End If
Next

Note this version does not validate controls nested within other container
controls, such as GroupBoxes, I would include the above in a recursive
subroutine.

The above code will cause the Validating event for each of your controls to
be raised, ensuring that all the controls get validated, before the dialog
is closed or the data is saved...

Hope this helps
Jay
"norton" <no********@hot mail.com> wrote in message
news:eB******** *****@tk2msftng p13.phx.gbl...
Hi All,
I am writing a simple win form which contains a button, when user click
the
button i want to validate all the other textbox and see if there is
anything
goes wrong

may i know how can i trigger the validating event for all text box?

thx and regard,s
Norton

Nov 21 '05 #3
Norton,

It sounds for me as a horse behind the car.

How can something be wrong in a textbox when you use correct the validating
event.
(Assuming you are not placing conflicting date in there by the program)

It will be executed as that control looses the focus.

What is it I miss?

Cor
Nov 21 '05 #4
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uo******** ******@TK2MSFTN GP09.phx.gbl...
.. . .
How can something be wrong in a textbox when you use correct the
validating event. .. . . It will be executed as that control looses the focus.
What is it I miss?


The User doesn't /have/ to Enter and Leave every control before
clicking the button ... Devilish things, these mouses .. er .. mice? ;-)

HTH,
Phill W.
Nov 21 '05 #5
Phill,

Now I understood you, in fact do you want to check if they are not empty?

However you can in my opinion for ever do (not tested)

sub ButtonClick event
textbox1_valida ting(textbox1,n othing)
textbox2_valida ting(textbox2,n othing)
etc.
end sub

As alternative for the already supplied options, while not knowing what
actions you take because of validationg errors.

Cor
Nov 21 '05 #6

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

Similar topics

6
5778
by: Alex Bink | last post by:
Hi, I have a validating event on a textbox in which I want to prevent the user to leave the textbox without entering the right data. Only if he clicks on another specific control he is allowed to leave the textbox without entering the right information. Is there a way to determine which other control was clicked in the validating event of...
7
7744
by: | last post by:
Hello to all I'm handling the Validating event for one text box. If something is wrong in user input I show a warning message. The problem is that if I add to method the message is displayed twice (event fired twice). Without event is fired once. if(txtMSG.Length > 0) {
2
1040
by: Fábio Prado | last post by:
I have one problem with events in a child form. I need raise a event to validate the textbox controls of child form when i click in one existent treeview menu in the Mdi parent and don´t allow that click event of the menu treeview raise when the event of texbox don´t be validated. Anybody have a solution? Thanks!
0
1545
by: Joe | last post by:
Hi For a while now I have been finding postings of problems with the validating event not firing on controls properly. I too had this problem. The event would fire when clicking on another control which had it's causes validation property set to true however if I tabbed on to this control the event wouldn't fire. So after playing around...
12
2923
by: Vittorio Pavesi | last post by:
Hello, is it possible to manually raise the event Elapsed of the timer object ? Vittorio
2
2112
by: Chris Dunaway | last post by:
I have a form with a textbox and numerous panels, buttons and other controls. I have handled the textbox Validating and Validated events. The textbox will hold a filename. In the validating event, I check that the string in the textbox is a file that exists or whether or not the string is blank and display a message box in either case. I...
0
2455
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls which are not behaving as I would expect. Specifically, if there is a command button external to the usercontrol which is activated by a shortcut...
0
2425
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852 (http://support.microsoft.com/kb/810852), but then I realized that the hotfix mentioned was in .Net v1.1, which I am using. I took the sample from that...
5
4688
by: Ian Jewitt | last post by:
Hi, I am having a problem where the validating event of a text box is not always firing. I am using vb.net 2003. I have an MDI application, one of the child forms contains a tab control
0
7468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7808
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7757
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.