472,973 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

An "All the time" event?

Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's
kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or
in another filed, I want that Total filed to be Updated...

/Lars
Nov 20 '05 #1
4 1237
Nope.

couple reasons.

1) Thats a lot of friggin events

2) Each event has its own signature. While many are the same, there are
many that are different. No "universal" event handler.

3) Not that many events fire on an ASP.NET page at once... Usually, 1...

4) If you want to catch something each time it happens in ASP.NET the
Page.Load event is always the first one fired, and you can validate whether
its a postback or not.

5) Look into storing values in the viewstate... or the session object.

hope it helps.

-CJ

"Lars Netzel" <[no_spam_please]la*********@qlogic.se> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or in another filed, I want that Total filed to be Updated...

/Lars

Nov 20 '05 #2
You could try hooking up all your controls Leave Events or Validating Events
(if you aren't using them for something else) to one event handler and call
your update form there.
"Lars Netzel" <[no_spam_please]la*********@qlogic.se> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or in another filed, I want that Total filed to be Updated...

/Lars

Nov 20 '05 #3
Lars,
In addition to CJ's comments.

Have you separated your UI from your Domain/Data objects? This should be
easy! In your domain objects as properties change, the Total property would
change. If you don't have Domain (business) objects per se and are binding
directly to Data objects (such as a DataSet/DataTable) you can use the
events on the DataTable itself to update to total fields. Such as
DataTable.ColumnChanged, DataTable.RowChanged and DataTable.RowDeleted.

An alternative:
Remember that an Event can be handled by more then one handler, and that a
single handler can handle events for more then one object.

The "problem" as CJ suggested, is that the signature of the event handler
needs to match the signature of the event. You may need two extra
handlers...

You could have an extra Changed event handler that would update the total
field, for each of the UI controls, they would have their own Changed event
handler, plus this extra Changed handler would handle the changed event.

Private Sub Text1_Changed(...) Handles Text1.Changed

Private Sub Text2_Changed(...) Handles Text2.Changed

Private Sub Text3_Changed(...) Handles Text3.Changed

Private Sub AnyText_Changed(...) Handles Text1.Changed, Text2.Change,
Text3.Changed
' calculate total amount
End Sub

You can use VS.NET to set the first three Changed event handlers, however
you will need to type in the third event handler.

Hope this helps
Jay

"Lars Netzel" <[no_spam_please]la*********@qlogic.se> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or in another filed, I want that Total filed to be Updated...

/Lars

Nov 20 '05 #4
Lars,
I should add, rather then using the Handles syntax to add the event handlers
on the Changed event handler you could use a For Each loop over the Controls
collection and use AddHandler to add the extra event handler.

Private Sub Form1_Load(...) Handles MyBase.Load
For Each ctl As Control In Controls
If TypeOf ctl Is TextBox Then
AddHandler DirectCast(ctl, TextBox).Changed, AddressOf
AnyText_Changed
ElseIf TypeOf ...
...
End IF
Next
End Sub

Note: if you have panels & other controls that may be nested, you may need
to make the above recursive on ctl.Controls!

Hope this helps
Jay

"Lars Netzel" <[no_spam_please]la*********@qlogic.se> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or in another filed, I want that Total filed to be Updated...

/Lars

Nov 20 '05 #5

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

Similar topics

10
by: KENNY L. CHEN | last post by:
Dear experts, I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO) and TEST1 (COL1,COL2,REC_NO). Both tables are unique-indexed on (COL1,COL2,REC_NO). I think the following...
0
by: Sham Yemul | last post by:
Hello, We developed an application that has many data entry forms and data controls in Vb.net and Sql Server2000 as backend. For this application we created connection object on load event of...
2
by: Dale Ring | last post by:
Access 2000 I am trying to add "ALL" to a combo that is used to filter a query. When "ALL" is selected no records show instead of ALL records showing. I have setup a "dummy" table (tblDum)...
9
by: rnn98 | last post by:
hi, my multithread application, running under solaris box, is crashing eventually. I tried to spot and substitute functions not "thread safe", but I guess my search wasn't good enough. I have put...
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
1
by: S.Guhananth | last post by:
I need to capture a country from dropdown list and use that in sql query. How to do this protected DataSet GetCountry() { I have the code for this block
17
by: teddysnips | last post by:
One of my clients has asked me to make a change to one of their Access applications. The application is a Front End/Back End standard app. I didn't develop it, but looking at it tells me that...
19
by: Daniel Pitts | last post by:
I have std::vector<Base *bases; I'd like to do something like: std::for_each(bases.begin(), bases.end(), operator delete); Is it possible without writing an adapter? Is there a better way? Is...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.