Discussion:
Start editing event in bindingsource ?
(too old to reply)
Merlin
2006-11-01 17:46:23 UTC
Permalink
Hi,

I can't find a way to catch something like a "start edit" event on a
bindingsource. This class has a EndEdit() method, that means it "knows"
that editing has been started... But how to be aware of this ?
bindingsource events doesn't seem to make the job.
Any idea ?
thanks.
--
//\/\\3rL1n_______
Bart Mermuys
2006-11-01 18:30:30 UTC
Permalink
Hi,
Post by Merlin
Hi,
I can't find a way to catch something like a "start edit" event on a
bindingsource. This class has a EndEdit() method, that means it "knows"
that editing has been started... But how to be aware of this ?
bindingsource events doesn't seem to make the job.
Any idea ?
There are some "shortcomings" when it comes to BeginEdit() and EndEdit().

The BindingSource is backed by a CurrencyManager. The CurrencyManager will
immediately call BeginEdit on the new current row and EndEdit on the
previous current row when the position changes. It does *not* wait until
you edit something.

HTH,
Greetings
Post by Merlin
thanks.
--
//\/\\3rL1n_______
Merlin
2006-11-01 20:51:52 UTC
Permalink
Post by Bart Mermuys
There are some "shortcomings" when it comes to BeginEdit() and EndEdit().
The BindingSource is backed by a CurrencyManager.
thanks for your answer.
I understand this very well, but my problem is to detect when editing
is started, no matter which row is under editing.
So I'm looking for some event that will be fired when BeginEdit() is
called.

example :
on a form I have a few textbox connected to a bindingsource (from a
typed dataset). When the user start to modify any field I want to be
warned.
At this time I have connected the "textchanged" event of all textbox to
a centralized event handler where I can set to true a flag. This is
working fine but I'm finding this solution not very smart... If the
bindingsource had a "StarEditing" event it will be smarter. So I'm
looking for an event, somewhere, in one of the instances
(bindingsource, dataset, datatable, rows collections, i dunno) that can
do this job.
Do you have any idea ?
--
//\/\\3rL1n_______
Bart Mermuys
2006-11-01 21:49:04 UTC
Permalink
Hi,
Post by Merlin
Post by Bart Mermuys
There are some "shortcomings" when it comes to BeginEdit() and EndEdit().
The BindingSource is backed by a CurrencyManager.
thanks for your answer.
I understand this very well, but my problem is to detect when editing is
started, no matter which row is under editing.
So I'm looking for some event that will be fired when BeginEdit() is
called.
But i already said BeginEdit is always called when the position changes.
Such an event would only be usefull if BeginEdit is actually called when the
user starts editing but it's not.
Post by Merlin
on a form I have a few textbox connected to a bindingsource (from a typed
dataset). When the user start to modify any field I want to be warned.
At this time I have connected the "textchanged" event of all textbox to a
centralized event handler where I can set to true a flag. This is working
fine but I'm finding this solution not very smart... If the bindingsource
had a "StarEditing" event it will be smarter. So I'm looking for an event,
somewhere, in one of the instances (bindingsource, dataset, datatable,
rows collections, i dunno) that can do this job.
You could use:
BindingSource.BindingComplete
DataTable.ColumnChanged

By default these will only fire when the Control is changed and validated
(see also Binding.UpdateDataSourceMode). The only other option is to use
your Controls changed events.

If you're using a DataSet/DataTable/DataView, you can also check if the row
is dirty using:

ValidateChilderen();
DataRowView drv = BindingSource.Current as DataRowView;
bool isCurrentDirty = drv.Row.HasVersion(DataRowVersion.Proposed);


HTH,
Greetings
Post by Merlin
Do you have any idea ?
--
//\/\\3rL1n_______
Merlin
2006-11-02 14:30:10 UTC
Permalink
But i already said BeginEdit is always called when the position changes. Such
an event would only be usefull if BeginEdit is actually called when the user
starts editing but it's not.
ok, so the answer is not in that direction.
BindingSource.BindingComplete
DataTable.ColumnChanged
By default these will only fire when the Control is changed and validated
(see also Binding.UpdateDataSourceMode). The only other option is to use
your Controls changed events.
It's what I'm doing, cause I want to warn at the begining of editing
process, not when the underlying table / column is updated.
If you're using a DataSet/DataTable/DataView, you can also check if the row
ValidateChilderen();
DataRowView drv = BindingSource.Current as DataRowView;
bool isCurrentDirty = drv.Row.HasVersion(DataRowVersion.Proposed);
It's a way but to be warn when editing is begining I'll have to use a
timer checking this all the time, and it is far less smart than my
current solution (ans the children validation can't be called with a
timer, this will be a mess).

Thanks for your help.
It's strange that MS did not think about such simple problems.
--
//\/\\3rL1n_______
Loading...