ObjectListView Problem

ObjectListView Problem

Old forum URL: forums.lhotka.net/forums/t/3211.aspx


gdk9am posted on Monday, July 16, 2007

I am having trouble with the ObjectListView with a DynamicRootList (EditableRootListBase)

My source list is list of editable root objects.

Filtering and sorting works properly.

However New or updated records are not saved to the database eventhough they are updated in the list on screen.

Can anyone give me a solution to this problem ?

 

 

 

JoeFallon1 replied on Tuesday, July 17, 2007

The ObjectListView acts differently than Rocky's SortedBindingList.

If you bind to the SortedBindingList then any changes made to it are really made to the underlying list.

When you bind to the ObjectListView you have to locate the correct object and take action on it. I do not think that databinding can do this for you but I am not sure.

Joe

 

gdk9am replied on Tuesday, July 17, 2007

Hi

Thanks for your answer

Can you provide some sample code which uses ObjectListView to persist records to the database ?

Graeme

 

Brian Criswell replied on Wednesday, July 18, 2007

The ObjectListView was developed before the EditableRootList came into being and so did not take it into account.  It does not pass a method call (most likely something in IEditableObject) to the underlying object because it handles undo on a row to row basis.  If you do not do this, then the object raises the PropertyChanged event when the properties are changed (even when in an edit) and the row is sorted or filtered immediately instead of when you move off of that row.  As an interim solution, I would recommend that you handle the event (I assume there is one) on the DataGridView that says the current row's values were kept and then save the object that corresponds to that row.

((MyClass)view[ i ].Object).Save();

Should save row i's object when you move off of row i.

Copyright (c) Marimer LLC