-
Oct 11th, 2005, 10:54 AM
#1
Thread Starter
Fanatic Member
Event Firing Order
I have been plagued with an issue that I cannot nail down. Here is the scenario:
I have a TextBox on a form that is bound using a typed DataSet. This TextBox contains a date. When the data is bound to this TextBox, I setup Format and Parse handlers. I also setup a Validating handler for this field for additional checking purposes.
Here is what is odd:
- Form1 Binds the data, adds handlers for the Format and Parse routines and lastly adds the handler for Validating. If I put in a bogus date, say 99/99/9999, my Validating routine alerts the user as planned. Events fire - Validating -> Parse -> Format
- Form2 does the exact same thing in the exact same order, but the Events fire - Parse -> Format -> Validating and the Validating routine gets the original database value passed in. (If I move the add handler code for Validating before the code that creates the handlers for Format and Parse, it works as intended.)
It appears that on Form2, the Parse and Format routines are realizing there is a bogus date and reverting it back to the value in the database.
Is there any way to control the order in which these events fire? This has been very painful as the events fire in a different order depending on what form they are on.
-
Oct 11th, 2005, 12:37 PM
#2
Thread Starter
Fanatic Member
Re: Event Firing Order
In debugging this situation, I moved the AddHandler statements for the Validating event into a separate SubRoutine. Now it works as intended on Form2.
This works
VB Code:
Private Sub frmMaintCompany_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call BindFormData()
Call SetupEventHandlers()
Call CreateDataset()
End Sub
Private Sub SetupEventHandlers()
' Add additional Handlers
AddHandler txtCurrentWorkDate.Validating, AddressOf AppRoutines.fDate_Validating
AddHandler txtCurrentWorkDate.TextChanged, AddressOf AppRoutines.f_TextChanged
AddHandler txtCurrentWorkDate.KeyPress, AddressOf AppRoutines.f_KeyPressNumeric
End Sub
This does not
VB Code:
Private Sub frmMaintCompany_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call BindFormData()
Call SetupEventHandlers()
Call CreateDataset()
' Add additional Handlers
AddHandler txtCurrentWorkDate.Validating, AddressOf AppRoutines.fDate_Validating
AddHandler txtCurrentWorkDate.TextChanged, AddressOf AppRoutines.f_TextChanged
AddHandler txtCurrentWorkDate.KeyPress, AddressOf AppRoutines.f_KeyPressNumeric
End Sub
Any idea on what is going on here?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|