Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datagridview not updating/refreshing

I have a DataGridView made of a DataSet of a table from the DB. When I delete a row, it is updated in the database but it is not removed from the GridView. Only when I restart the application does it get removed from the GridView.

Please help

like image 293
user966614 Avatar asked Nov 05 '12 11:11

user966614


2 Answers

You need to reset the binding on your bindingsource.

bindingSource.ResetBindings(false);
like image 104
helgeheldre Avatar answered Nov 14 '22 08:11

helgeheldre


This is a very simple process.

1.) Create a Binding Source

2.) Set the Datasource for this object to your Dataset Table.

3.) Set The datasource for your DatagridView as the Binding source Object.

Code Example:

Dataset ds = new Dataset();
BindingSource bs = new BindingSource()
bs.Datasource = ds.Table[0];
DatagridView.Datasource = bs;

Now, Any changes you make in the DataTable will ripple through to your GridView automatically.

like image 35
Derek Avatar answered Nov 14 '22 06:11

Derek