I have small problem - my BindingListView<T> is the data source for a DataGridView. I edit objects from code (the grid is readonly) like this:
ObjectView<T> objView = ... here I get object from list;
objView.BeginEdit();
// here goes editing, e.g.
objView.Object.Name = "some name";
objView.EndEdit();
After call to EndEdit, the DataGridView properly shows new value of that object, and this is correct.
BUT when I first add a new object form code (using AddNew() and the corresponding event), and then I edit the object using the above procedure - the DataGridView keeps showing old value. I have to call DataGridView.Refresh() to make it display new value.
I add objects like this:
BindingListView<T> myList = ...
ObjectView<T> newObjView = myList.AddNew();
void myList_AddingNew(object sender, AddingNewEventArgs e) {
e.NewObject = someObject;
}
I have additional question here, how am I supposed to know the item index to be passed to the methods BindingListView<T>.EndNew(int index) and BindingListView<T>.CancelNew(int index)? I don't see any way to get that index, like BindingListView<T>.IndexOf(...) or anything like that.
Thanks in advance for any help =)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have small problem - my BindingListView<T> is the data source for a DataGridView. I edit objects from code (the grid is readonly) like this:
ObjectView<T> objView = ... here I get object from list;
objView.BeginEdit();
// here goes editing, e.g.
objView.Object.Name = "some name";
objView.EndEdit();
After call to EndEdit, the DataGridView properly shows new value of that object, and this is correct.
BUT when I first add a new object form code (using AddNew() and the corresponding event), and then I edit the object using the above procedure - the DataGridView keeps showing old value. I have to call DataGridView.Refresh() to make it display new value.
I add objects like this:
BindingListView<T> myList = ...
ObjectView<T> newObjView = myList.AddNew();
void myList_AddingNew(object sender, AddingNewEventArgs e) {
e.NewObject = someObject;
}
I have additional question here, how am I supposed to know the item index to be passed to the methods BindingListView<T>.EndNew(int index) and BindingListView<T>.CancelNew(int index)? I don't see any way to get that index, like BindingListView<T>.IndexOf(...) or anything like that.
Thanks in advance for any help =)