I am working on a .NET project, and with a Delphi VCL background you really miss a TNavigator for a starter.
So lets build a Navigator ourself. A navigator is a bunch of buttons (First, Prior, Next, Last, Insert, Delete, Post, Cancel etcetera)
A great advance of using a navigator that it encapsulate a lot of code, so that you spare extra code on each form where you use it. It also has the ability to context sensitive act to changes (read events) in the data that it is navigating. So make a control, give him a DataSet and a Table name and go........well it is not that simple!
It is bugging me few days now that I can not find any event in ADO.NET that 'tells' me that the data is edited. I mean at the first keystroke of the user, so that the Post and Cancel buttons of the navigator can become active.
Lets explore some events of the main ADO.NET components:
The DataTable
The datatable seems to me the most logic choice for such an event. It has the following events:
- ColumnChanging
- ColumnChanged
- RowChanging
- RowChanged
If you examine(try) this events you will notice that they all fire after the actual edit, and that is to late!
The DataView
The DataView has only a listchanged event which does not help us at all.
The DataRow
The datarow has a property RowState, which changes after an edit occurs, but it has no OnRowStateChange event.
The CurrencyManager
The CurrencyManager manages a list of bindingobjects, and that are our controls. The CurrencyManger has the following events:
- CurrentChanged
- ItemChanged
- MetaDataChanged
- PositionChanged
They sound promising, but again they fire after the actual keystroke.
So as far as I know there is no event in ADO.NET like the VCL TDataSet BeforeEdit and AfterEdit event. It seems to work in other way in .NET and the only solution I can think of is tracking the OnChange events of the controls on the form.
What am I missing?
1 comment:
I've run into the same issue. Something like this is easy in Delphi yet non-existent in dot net. Did you ever find a solution? I'm about to try looping through all the columns in the DataRow and setting an Event Handler on the ColumnChanging event for each column. don't know if it will work, but can't believe there is not an easier method.
Post a Comment