1 Replies - 540 Views - Last Post: 02 February 2012 - 10:55 PM Rate Topic: -----

Topic Sponsor:

#1 bry090911  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 93
  • Joined: 02-February 12

Question how to refresh the datagridview?

Posted 02 February 2012 - 07:38 PM

When i finish inserting/updating the datagridview doesn't refreshing..

i tried..

datagriview1.refresh
datagridview1.refreshedit


Is This A Good Question/Topic? 0
  • +

Replies To: Question how to refresh the datagridview?

#2 demausdauth  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 162
  • View blog
  • Posts: 563
  • Joined: 03-February 10

Re: Question how to refresh the datagridview?

Posted 02 February 2012 - 10:55 PM

How did the DataGridView object get filled to begin with? At some point you had to set datagridview1.DataSource. What you need to do is re-run this piece of code. This is why when I am dealing with a DataGridView or similar object I like to create a FillData method.

Public Sub FillData()
     'Make connection to database
     'Call whatever SQL with whatever criteria it needs to get the relevant data
     'Return to a DataSet
     Dim dataSet As DataSet = GetMyData()
     datagridview1.DataSource = dataSet.Tables(0)

End Sub


That is a very stripped down version. But as you can see there is now a method separate from any event (not in the Load Event) to fill the datagridview. Now you can call the method after updates, deletes, and insertions, to get the freshest data.

That is all assuming you are doing it at a basic level and not using a tableadapter or a bindingsource. For those I would point to MSDN about 2/3 the way down the page.MSDN DataGridView
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1