The implementation of IBindingList in this example is not entirely correct.
That is probably why this example has been removed from the current version
of MSDN. The problem is that according to IBindingList MSDN doc "When you
call the AddNew method, you should raise a ListChanged event with the
ItemAdded enumeration carrying the appropriate index. The added row is in a
state where pressing the ESC on a DataGrid control can remove the new row.
Raising the ListChanged event with the ItemAdded enumeration a second time on
this row indicates that the item is now a row not in the "new" state"
In essence, the implementation of IBindingList should be statefull. When new
row is created ListChanged should fe fired twice - once with AddItem
parameter and second time with ether AddItem or RemoveItem depending of what
was the reult of item editing (EndEdit/CancelEdit)
If you use an example as is everything looks ok at a first glance, however
you will notice that the collection grows in size as you move focus away from
the grid and back. If you delete any of the newly created rows you may
encounter “Index Out Of Range” exception or other data binding issues
I have working sample now for anyone who's interested.
Boris
Sameer Khanna - 13 Sep 2004 06:55 GMT
I have similar type of problems when using MSDN example. It gives me
stackoverflow exception when assigning the datasource to my own
collection for the datagrid. Please send me some sample program at
sameer.khanna@ihealthcareinc.co.in. Thanks
Sameer Khanna - 13 Sep 2004 07:05 GMT
I have a similar type of problem but i got stackoverflow exception. i
have used the msdn example. please send me some good samples.
sameer.khanna@ihealthcareinc.co.in
thanks...sameer
Knut Vonheim - 01 Oct 2004 17:49 GMT
Boris,
I came across your message in my attempt to implement IBindingList.
I would love to see the sample code you have!
Do you implement Find and the other methods that typically throw an
exception?
TYIA,
Knut
> The implementation of IBindingList in this example is not entirely correct.
> That is probably why this example has been removed from the current version
[quoted text clipped - 18 lines]
>
> Boris
BorisDotNet - 06 Oct 2004 12:13 GMT
Hi Knut
We don't implement Find and others. Please send an e-mail to
boris@NOSPAM.qbf.com.au and i'll reply with the sample
cheers
boris
> Boris,
>
[quoted text clipped - 38 lines]
> >
> > Boris
Marcelo Duarte - 02 Oct 2004 23:33 GMT
BorisDotNet
You said :
"The implementation of IBindingList in this example is not entirely
correct.
That is probably why this example has been removed from the current
version
of MSDN. The problem is that according to IBindingList MSDN doc "When
you
call the AddNew method, you should raise a ListChanged event with the
ItemAdded enumeration carrying the appropriate index. The added row is
in a
state where pressing the ESC on a DataGrid control can remove the new
row.
Raising the ListChanged event with the ItemAdded enumeration a second
time on
this row indicates that the item is now a row not in the "new" state"
In essence, the implementation of IBindingList should be statefull. When
new
row is created ListChanged should fe fired twice - once with AddItem
parameter and second time with ether AddItem or RemoveItem depending of
what
was the reult of item editing (EndEdit/CancelEdit)
If you use an example as is everything looks ok at a first glance,
however
you will notice that the collection grows in size as you move focus away
from
the grid and back. If you delete any of the newly created rows you may
encounter ???Index Out Of Range??? exception or other data binding
issues
I have working sample now for anyone who's interested.
Boris".
Can you sendme a simple sample of class and collection where
IBindingList and IEditableObject and correctly implemented ? You can
find me at M_Duarte at yahoo.com
Thanks ;-)