CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    19

    Question How to "refresh" a Datagridview?

    Hi
    In Form1 I have a Datagridview showing the content of a table from DataBase.

    In Form2 I add or modify a row in that table. So, when I get back to Form1 I would want the DataGridView get updated automatically.

    To populate the DGV I use a Linq To Sql query:
    Code:
    Dim Query = From .....
    Me.DGV.DataSource = Query
    or

    Code:
    Dim Query = From .....
    Me.BindingSource1.DataSource = Query
    Me.DGV.DataSource = Me.BindingSource1
    I have been trying to use:
    BindSource (as DataGridView.DataSource)
    BindingSource.ResetBinding(False)
    DGV.Refresh()
    etc...

    Also, I added a new row in the same Fomr1 and nothing happens.

    Thanks for advance !!!

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to "refresh" a Datagridview?

    Be sure you really modify the db and not only a local in memory representation of it in form2.

    Then, you first, you should make form 2 inform form 1 it is time to reload (requery) data.

    To refresh data in form 1 use
    Code:
    BindingSource1.ResetBindings(false)
    On how to inform form1 from form2 it is time to refresh, have a look at delegates and callbacks. But take this advice: look also at async operations...
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured