I'm trying to display a DataTable using a DataGridView and a BindingSource as such: (assuming the DataGridView1 and BindingSource1 has been added using the IDE)
This works fine most of the time; deleted rows from the DataGridView are reflected back on the table, and added rows using table.Rows.Add() are reflected on the DataGridView as well.Code:Dim table As New DataTable ' 'populate table with some data here ' BindingSource1.DataSource = table DataGridView1.DataSource = BindingSource1
However, when I try to change the entire table the BindingSource failes to update the DataGridView:
I tried to use BindingSource1.ResetBindings() method but that didn't work; the DataGridView was redrawn but still showed values from the old table. The only thing that did work was this:Code:Dim NewTable As New DataTable ' 'populate NewTable with some data here ' 'set the table to NewTable table = NewTable
However this is not the best solution to my problem since the table is actually being changed by a parent forum. Is there a way to cause the BindingSource to update automatically in this scenario?Code:BindingSource1.DataSource = Nothing BindingSource1.DataSource = table




Reply With Quote