473,378 Members | 1,309 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,378 software developers and data experts.

Call control's event from a collection

I pass my form's collection of controls to a public sub in a module
that loops through and checks for any ErrorProvider text. The sub
returns all the ErrorProvider strings that were found for display in a
msgbox to let the user know that there were data errors found. This
works great, however, sometimes a user does not ever enter a certain
control, therefore that control's validating event is never called, so
my Error collecting sub will not return anything for this control. I
need to be able to loop through all controls on a form and call each
control's validating event. I need this code to be reusable for
multiple forms. Any suggestions.

This does not work:

Public Function CallEventOfCtrl( Controls as controlcollection) as
string
for each c as control in Controls
c.Validated
'or
call c.validated
next
End function

Apr 12 '06 #1
3 2915
"Bryan" <br*******@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
I pass my form's collection of controls to a public sub in a module
that loops through and checks for any ErrorProvider text. The sub
returns all the ErrorProvider strings that were found for display in a
msgbox to let the user know that there were data errors found. This
works great, however, sometimes a user does not ever enter a certain
control, therefore that control's validating event is never called, so
my Error collecting sub will not return anything for this control. I
need to be able to loop through all controls on a form and call each
control's validating event. I need this code to be reusable for
multiple forms. Any suggestions.

This does not work:

Public Function CallEventOfCtrl( Controls as controlcollection) as
string
for each c as control in Controls
c.Validated
'or
call c.validated
next
End function


Warning... VB6 answers are all I have but... doesn't dotNet have a
ValidateControls method? Events aren't really something you should call
directly. Especially for controls that have no code in that specific event.
In VB6, ValidateControls raises the Validate event for any control that
currently has focus. I'm sure dotNet has something similar... well... ran
ValidateControls through the "one eyed wizard" and it spits out...

Call VB6.ValidateControls(Me)

....so it's a start.

--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..
Apr 12 '06 #2
..net has support for the ValidateControls method, but it is only used
for projects that are being upgraded from from VB6. Each control in
the collection has a validated event, but control events don't seem to
be accessible from outside their parent form.

Apr 12 '06 #3
..net has support for the ValidateControls method, but it is only used
for projects that are being upgraded from from VB6. Each control in
the collection has a validated event, but control events don't seem to
be accessible from outside their parent form.

Apr 12 '06 #4

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

Similar topics

10
by: James McGivney | last post by:
I have a project in ASP.NET using C#. I have a large number of Button Controls and a large number of ImageButton Controls. It would be convienent if I could refer to a specific control by it's...
5
by: Andrei Pociu | last post by:
Inside a method some controls are created at runtime. I added an event handler to one of these controls: tracker.Scroll += new System.EventHandler(this.tracker_Scroll); So in the event handler...
5
by: Dan | last post by:
Hi, I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no...
8
by: John Smith Jr. | last post by:
I am looking for some way to persist a table web control so when page_load event comes up, i can display the table as it was. I tried using ViewState with the rows collection but that didn't work...
4
by: Remi Hugnon | last post by:
Hi, I want to build an expandable treeview. I saw some code on VB but I know only C# I plan for my class that each nodes has its own id (using span for example). Into a single aspx page...
1
by: Jeff Evans | last post by:
Hi, I was wondering if it's possible to remove a Control c from a Controls collection in the parent's event handler for an event fired by c. For instance let's say we have public class...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
3
by: --== Alain ==-- | last post by:
Hi, I have a control which has a collection property. when an item of the collection property will be added, removed, and so on, i would like to refresh the control itself. Usually for that i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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: 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...

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.