Datagrid : IBindingList question

  • Thread starter Thread starter Matthew Woods
  • Start date Start date
M

Matthew Woods

bool A = Is this the right place to ask this question?

if (A)
{
Where can i find a good example of an ArrayList bound to a datagrid that
automatically updates the grid when the public data within the class
contained in the arraylist is updated. i do not want to use
datagrid.refresh() because the data updates randomly and often frequently
and refreshing the whole grid several times a second is expensive and causes
a flicker.
}
else
{
please redirect me to the appropriate newsgroup.
}

thanks
Matt
 
ArrayList does not implement IBindingList which is why it doesn't update the
grid.

The best solution is to create your own IBindingList implementation.

The only framework classes that I know of that implement IBindingList are
DataView and DataViewManager.

Pete
 
Thanks,

So is there any way to automatically update a datagrid bound to an
arraylist?

Matt
 
No, there is not. However, you can create a regular wrapper which takes
an ArrayList which implements IBindingList. It wouldn't be too hard.

Also, if you are using .NET 2.0, check out the BindingList<T> class, as
it implements IBindingList, and will give you what you want.

Hope this helps.
 
I think you call Refresh() in the CurrencyManager. I'm pretty sure that will
work.

Just do:

(BindingContext[grid.DataSource, grid.DataMember] as
CurrencyManager).Refresh();

Pete
 
Calling CurrencyManager.Refresh() will cause it to resync with the
datasource, allowing it to pick up the changes. There are problems with
this, and I agree, wrapping ArrayList and implementing IBindingList is far
preferable.

Pete

Nicholas Paldino said:
No, there is not. However, you can create a regular wrapper which
takes an ArrayList which implements IBindingList. It wouldn't be too
hard.

Also, if you are using .NET 2.0, check out the BindingList<T> class, as
it implements IBindingList, and will give you what you want.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Matthew Woods said:
Thanks,

So is there any way to automatically update a datagrid bound to an
arraylist?

Matt
 
Back
Top