w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
how to restore a minimized form from another form's button click and closing the second form too

You could create a public method in form1 that restores it and refreshes the dataGridView data:

Create a public method in Form1:

public void RestoreAndRefresh()
    {
        this.Show();
        dataGridView1.DataSource = dt; //Or perform the refresh rutine you
want.
    }

In Form2 add a variable of type Form1:

public From1 f1Parent {get; set;}

When you create Form2 in Form1 just add the following lines:

Form2 f2 = new Form2();
f2.f1Parent = this;
f2Show();

And in the end, in Form2's Ok and Cancel buttons add these lines:

f1Parent.RestoreAndRefresh();
this.Close();

You will need to adjust RestoreAndRefresh method to your needs, but it should restore Form1.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.