Show Form2
as a modal dialog, which will prevent code after it from running until the form is closed.
Then move the logic from button3_Click
to right after the form is displayed, like this:
private void button2_Click(object sender, EventArgs e)
{
using (Form2 form2 = new Form2())
form2.ShowDialog();
this.carsTableAdapter.Fill(this.databaseDataSet1.Cars);
this.driversTableAdapter.Fill(this.databaseDataSet1.Drivers);
}
Remove the following code from button1_Click
on the second form. It's not doing anything useful anyway, since you're creating a new instance of Form1
that has no relation to the current instance that's displayed to the user.
Form1 form1 = new Form1();
form1.button3_Click(this, new EventArgs());