Click here to Skip to main content
15,910,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a main window which contains a user control with a datagridview control which is used to display a list of records in a database table(s). If the user wants to add a new record, they click "new" and a popup window displays. The popup window accepts data from the user (name, number, date, etc) and is then submitted back to the server when the users clicks a save button. At this point I want to update the database with the new record, close the popup window, and then refresh the main window datagridview so that it reflects the newly added record that was created using the popup window.

Here is the code to open the popup window
VB
frmRelaties_Contactpersonen.txtRelatieNaam.Text = cboRelatieNaam.Text
frmRelaties_Contactpersonen.Show()

How to refresh the datagridview on the main window when the popup window is closed?
Posted
Updated 6-Dec-10 12:56pm
v2

1 solution

The answer really depends on how you are binding the DataGridView to the Database.

If you are not using a BindingSource, the only way I know is to set the DataSource to null, then set it back to the correct value. This should cause it to refresh.

If you are using a BindingSource[^], it should refresh automatically, but if, for some reason, it doesn't you can use the BindingSource.ResetBindings()[^] method to force it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900