472,352 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 9152
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 CausesValidation to ensure that they are all valid...

Something like:

For Each control As control In Me.Controls
If control.CausesValidation Then
control.Focus()
If Not Me.Validate() Then
Me.DialogResult = DialogResult.None
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********@hotmail.com> wrote in message
news:eB*************@tk2msftngp13.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**************@TK2MSFTNGP09.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_validating(textbox1,nothing)
textbox2_validating(textbox2,nothing)
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
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...
7
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...
2
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...
0
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....
12
by: Vittorio Pavesi | last post by:
Hello, is it possible to manually raise the event Elapsed of the timer object ? Vittorio
2
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...
0
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). ...
0
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...
5
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...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.