CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  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:
    Query = From ..... ;
    Me.DGV.DataSource = Query;
    or

    Code:
    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 !!!
    Last edited by LeoVB; February 16th, 2014 at 02:16 PM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to "refresh" a Datagridview?

    What language do you use? The pseudo code you have "posted" does not look like VC++.
    Victor Nijegorodov

  3. #3
    Join Date
    Apr 2013
    Posts
    19

    Re: How to "refresh" a Datagridview?

    Quote Originally Posted by VictorN View Post
    What language do you use? The pseudo code you have "posted" does not look like VC++.
    Hi Victor

    You're right. I'm using Visual Basic (2012), but I think I can get an approach coming from C# or C++.

    If you can help me, please remember I'm not modifyng the DGV but the table from DataBase. It's the same if I do so in another Form (Form2) or in the same Form where DGV belongs to.

    Simply, DGV is 'bound' to a query through DataSource property. So, when data is added or modified inside the DataBase I need the DGV reflects that change automatically and not to have to reload the query from the beginning. Therefore, it doesn't matter where the DataBase is update.

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