How to refresh a DataGrid?

G

Guest

Hi,

This might be the easiest question ever but I can't seem to find how to do
it: I have a DataGrid that's linked to an instance of IList (actually, it's
an ArrayList). On load, there's already data in the collection so when I
call the DataGrid's 'SetDataBinding' method, the DataGrid displays the data
correctly.

Problem is that when I add data to the collection afterwards, I can't
display it in the DataGrid. I tried calling its 'Refresh' method, its
'Update' method and even the 'SetDataBinding' method again without success.

Basically, in this case, how can I refresh the data in a DataGrid once the
source has changed?

Thanks,

SC
 
N

Nicholas Paldino [.NET/C# MVP]

SC,

You could set the DataSource of the grid to null, and then back to the
list. This is the hacky way.

If you wanted the grid to update when changes are made, then implement
the IBindingList interface, which has an event that you fire when changes
are made to your list.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top