C Perkins - 2013-08-22

I have a DataRepeater with a TextBox bound to a string field in a list. Prior to implementing the BindingListView, I had successfully bound directly to an array of MyObject and then to a BindingList<MyObject>, with the TextBox bound to MyObject.Text. Prior to implementing BindingListView, if I changed focus using the mouse during an edit (i.e. the TextBox text was changed) to another DataRepeaterItem or to any other control on the form, the edit would be applied/saved automatically without having to first click the record header, etc.

However, after binding to a BindingListView<MyObject>, the edited text is lost if I change focus using the mouse to another DataRepeaterItem. The edited text is correctly accepted/saved if I move between fields using the Tab key or if I change focus to outside the DataRepeater control. (Everything else works beautifully, including sorting and filtering, but it's a real drawback to inadvertently loose edited data by clicking between records.)

I have verified the undesired behavior using different sources and data types. (The problem also happens with CheckBoxs bound to Boolean fields, as an example.) I have also tried to fix the problem by subscribing to every possible focus-type and ItemChange-type event (e.g. LostFocus, Leave, ListItemChanged) on the DataRepeater and the BindingSource object. I've also tried to find the responsible code in the BindingListView source code to no avail. The change to the underlying list is always persisted before any of the events fire or code entered that I can reach. There is obviously a difference in behavior between this and other Framework lists, but I can't find where the actual validation and update to the list object takes place. It seems the actual code which saves the edited TextBox is unreachable within a Framework CurrencyManager, BindingSource, etc.

I'm not providing code immediately, because since it's so basic and it works as expected with other basic lists, there is really nothing special or peculiar to show. I simply followed the "one line" approach shown in the video demonstration to implement the DataListView. That's it.

 

Last edit: C Perkins 2013-08-22