I don't know if this has really been solved or not... but by looking at all the other answers, nothing seems quite clear. The best way I found to do this is to put the same code, that was used to populate your datagridview
into a method and pass it your form's datagridview
, as so:
public void ConnectAndPopulateDataGridView(DataGridView dataGridView)
{ }
The code within the method is the exact same as the code used to populate the datagirdview
originally, except for the datagridview
name changing to whatever you called it in your method.
Now this method is called in your parent form.
The child form is launched via a .ShowDialog()
then the method is called after so that it is called right after the child for is closed... as so:
ChildForm.ShowDialog();
ConnectAndPopulateDataGridView(dataGridView1);