I have a DataGrid bound to a custom collection that implements
IBindingList. It is well known that updates to windows forms widgets
must be done on the same thread as the form. Here is the kicker: I
would like to have a process in a separate thread that makes updates
to the collection. Ideally what I would like is for the DataGrid to
call Invoke() when it receives the ListChanged event, before updating
itself. Is there a correct way to do this?
I have worked around this issue by implementing my collection as a
derivative of IList, instead of IBindingList so that updates to the
list in a separate thread don't cause a refresh on the DataGrid. What
I do then, is implement a custom ListChanged event on my collection,
and I wrap the DataGrid in a separate component that listens for the
event - calling DataGrid.Refresh() through an Invoke.
This works great, however, the 'whole' Data grid gets refreshed every
time a single row changes, which causes a bit of flicker.
Any thoughts on how to properly update an IBindingList in a separate
thread? This seems like an obvious thing to need to do...
Cheers,
- Julien
Julien Sellgren - 10 Nov 2004 22:02 GMT
I suppose another solution would be to fire the ListChanged event
using control.Invoke() from within the collection. This would mean
that the collection would need to be 'aware' of the datagrid however,
which I am not keen on. Any other thoughts on this issue?
- Julien
> I have a DataGrid bound to a custom collection that implements
> IBindingList. It is well known that updates to windows forms widgets
[quoted text clipped - 20 lines]
>
> - Julien