Datagridview not updating/refreshing

前端 未结 5 1497
忘掉有多难
忘掉有多难 2020-12-17 20:25

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 rest

5条回答
  •  时光取名叫无心
    2020-12-17 21:16

    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.

提交回复
热议问题