0

i have got a datagridview which is databind to a bindingsource, that bindingsource is a list....what i did was to update the value at the datagridview but the list did not get updated.

 private void BindDataSourceToGridview()
 {
 BindingSource bindingSource = new BindingSource();
 bindingSource.DataSource = objectList;
 datagridview1.AutoGenerateColumns = false
 datagridview1.DataSource = bindingSource;

 reCalculateIndex(datagridView1);

 datagridview1.EndEdit();
 datagridview1.Refresh();
 }

 private void reCalculateIndex(Datagridview datagridView)
 {
 int index = 1;
 foreach (DataGridViewRow row in datagridView.rows)
 {
 row.Cells[0].Value = index;
 index++;
 }
 }

how can i refresh the list after doing this?

1 Answers1

0

You should check this: How to refresh a bindingsource

It suggests to try to set the DataSource to null and then reset to the objectList value. As an alternative you can implement the inotifypropertychanged interface

Community
  • 1
  • 1
MaPi
  • 1,601
  • 3
  • 31
  • 64
  • my case is alittle bit different, ive got the gridview displayed nicely but the underlying objectList which is the datasource did not get updated when i tried to use it somewhere else –  Aug 05 '14 at 07:44