Overriding CurrencyManager Behavior in UserControl -
09-21-2004
, 04:30 AM
Hello,
I've a usercontrol which has no explicit databinding. After
attaching a datasource to a public property it appears that
the CurrentChanged event of the BindingContext will fired
every time the control lost focus, even if the content of
the property was not changed.
I thought that overriding the OnCurrentChanged method of the
CurrencyManager object, but I've no clue how to get this.
I've tried to use this code to get the manager from
DataBindings CollectionChanged event:
private void DataBindings_CollectionChanged(object sender,
CollectionChangeEventArgs e)
{
if (e.Action == CollectionChangeAction.Add)
{
cm = ((Binding) e.Element).BindingManagerBase as
CurrencyManager;
cm.CurrentChanged += new EventHandler(cm_CurrentChanged);
cm.ItemChanged += new ItemChangedEventHandler(cm_ItemChanged);
}
}
This handler is reached and the event handlers are attached,
but the events cm_CurrentChanged and cm_ItemChanged are
never fired. Instead, the CurrentChanged event is still activ
on each focus lost.
Please, can anybody give me pointer to UserControl databinding?
I've already read most of MSDN and NoiseEHC's very good articles,
but still no idea...
Thanks,
Joerg |