简体   繁体   中英

How to update a datagridview with updated sql table in C#?

I have a DataGridView in a WinForms App and I fill it with a table from a database (local database, table is called ' table '). When I update the table within the C# code the changes takes effect in the Database but are not shown in the DataGridView.

How can I update the DGV? I've found dataGridViewStock.Refresh(); and dataGridViewStock.Update(); but none of these two worked.

Anybody has a tip for me?

after updating your datatable in c# you may simply write

yourDataGridView.DataSource=null;
yourDataGridView.DataSource=dt;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM