RowChanged event handler removed after Clear


Author
Message
MarcoR
MarcoR
StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)
Group: Forum Members
Posts: 15, Visits: 39
I register a CurrentDataTable.RowChanged event handler during initialization. After a call to the Clear method I notice it is no longer called. Is there a better event to hook into for the same notification that carries across the CurrentDataTable being renewed?
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I believe there is an event fired by BOs when the data table is loaded (can't remember the name of it at the moment). You might try setting the row changed event handler there. That way it would be reset whenever it is reloaded.
StrataFrame Team
S
StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, you will want to add a handler to the CurrentDataTableRefilled event as well and inside of that handler, remove the RowChanged handler from the old DataTable and add it to the new CurrentDataTable (you'll need to store off a reference to the DataTable you've attached to so that you can remove the handler from it).  When you refill a business object, the old object is disposed and a new DataTable is created, so your event handler it attached to the "dead" DataTable, not the live one.  So, add the handler initially, just like you're doing now, but also add a handler to the CurrentDataTableRefilled event on the same business object and when it's fired, remove the old RowChanged handler and add a new one.

FYI, you might want to look into attaching to the CurrentDataTable.DefaultView.ListChanged event.  It tells you almost everything that the RowChanged event does, but it also tells you what column changed when a new value is set on a field.

MarcoR
MarcoR
StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)StrataFrame Beginner (19 reputation)
Group: Forum Members
Posts: 15, Visits: 39
Thanks! I had a temporary fix using a

new public void Clear()

, but this is much cleaner (and also works when cast to the base class Smile ).
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search