开发者

Quickest/simplest way to refresh datagridview?

I have problem with updating my datagridview after inserting new data t开发者_如何学Pythono table. It seems DataSet ,to which datagrid is bound, does not refresh and i cant force it to do so.The only way to refresh dataset is to reset application. I know i can make new DataSet and fill it with table's data every button "Refresh" click ,but i wonder if its simpler way.

I googled a little, but non of these solutions work for me :

  • bindingSource1.EndEdit();
  • bindingSource1.ResetBindings(false);
  • dataGridView1.EndEdit();
  • dataGridView1.Refresh();
  • dataGridView1.Parent.Refresh();
  • dataSet1.GetChanges();
  • this.TableAdapter.Fill(this.dataSet1.Table1);
  • dataGridView1.Invalidate();

Where the problem lies?


Changes to the dataset will be reflected in any bound grids. But it sounds like what you're asking is how to make the DataSet itself update in response to changes in the underlying database table. There's nothing automatic in .NET or MSSQL for this. You basically have to just re-run your query. You want to have a look at the ClearBeforeFill property of the table adapter so that you are not blowing away existing data when loading in new changes.

Have a look at this article for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜