c# - Bindingsource is not suspending binding -


i have form displays custom details, 1 section being list of bank accounts associated customer. list bound it's own bindingsource, when loading customer do:

bscustomer.datasource = customer; bscustomeraccounts.datasource = customer.accounts; 

i have objectlistview bound bscustomeraccounts. far works fine.

to edit particular account, double-click on , open separate form:

using (var form = new customeraccountform(selectedaccount)) {     dialogresult result = form.showdialog(this);     if (result == dialogresult.ok)     {         selectedaccount= form.account;     } } 

the problem when user clicks on cancel cancel editing of account in form. original bccustomeraccounts , therefore list still being updated.

i've tried suspendbinding , raiselistchangedevents = false bindingsource still being updated.

am missing something?

it seems surprising @ first, think while didn't assign edited object list, why list item edited?

the key point here: classes reference type.

you passed selected account edit form , since it's class , classes reference type, in fact editing same instance in list. when edit properties, edits directly applying object regardless of clicking ok or cancel.


Comments

Popular posts from this blog

Python Pandas join aggregated tables -

java - Static nested class instance -

process - Python What is the difference between a Pool of worker processes and just running multiple Processes? -