EndCurrentEdit gets called automatically, Data changes in more than one row

The situation is - We have our own control called DbTextBox which has the ability to autobind to datasource and which stores it's unparsed value (ints, floats, ...) inside so we just don't have to setup the binding on every single form, .... When I leave the control so it's looses focus the validating event occurs and our internal validator parses and validates the input in .Text property and if OK it assignes the internall cached unparsed value (respectivelly parses the .Text input as beeing int or whatever and saves the value), and if binded to datasource (even it's called DbTextBox could be used as unbinded to act just as a validated TextBox) than we propose the changes to the binded DataSource:

((DataView) this.MyBinding.MyBindingManagerBase.DataSource)[this.MyBinding.MyBindingManagerBase.Position][this.MyColumnName] = this.Value;

and here's the problem I encountered. When this line get's executed BindingManager's Position property gets changed (because EndCurrentEdit is called automatically - WHY ) - that would not be the worst because after EndCurrentEdit it's normal to change the position is the data changed the way that position in sorted data changed, the problem is that happens this:
DATA
before the line:
SomeColumn 1
SomeColumn 2
...

my change:
SomeColumn 1 => foobar (sort is on SomeColumn 1 so i want the data to change it's position)

after the line: (BM_PositionChanged occured)
data at original position
foobar
SomeColumn 2
...

data at new position - and this now stays as Current so data in whole change
foobar
SomeOtherColumn 2
...


I was thinking about it, spent yesterday debugging through it and googling but didn't found anything at all.

Did anybody had the same problem, or does anybody see any huge mistake in the code which i don't see. Thanks for any advice Milan


Answer this question

EndCurrentEdit gets called automatically, Data changes in more than one row

  • Rafael Nami

    Please paste the code used to create MyBinding. Also, you may want to remove any binding managers from the BindingContext of the form you're working with before creating and adding others.

  • EndCurrentEdit gets called automatically, Data changes in more than one row