473,382 Members | 1,369 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,382 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 9302
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 clicks on another specific control he is allowed...
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 that if I add to method the message is displayed...
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 treeview menu in the Mdi parent and don´t allow that...
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. The event would fire when clicking on another...
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 textbox will hold a filename. In the validating...
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). I have controls (textboxes) within UserControls...
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 issue in the Knowledgebase article 810852...
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 application, one of the child forms contains a tab...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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...

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.