-
February 16th, 2014, 02:13 PM
#1
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.
-
February 16th, 2014, 02:23 PM
#2
Re: How to "refresh" a Datagridview?
What language do you use? The pseudo code you have "posted" does not look like VC++.
Victor Nijegorodov
-
February 16th, 2014, 04:50 PM
#3
Re: How to "refresh" a Datagridview?
Originally Posted by VictorN
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|