Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute function on another, already open, form

I have a form with a datagridview inside of it.

When you doubleclick on a row from the datagridview, another form will open, which is basically a form where you can edit the data you just double-clicked.

There are a 3 buttons in this "edit" form, a delete, update and a return to main form button.

When finished with what you were supposed to do on this form, it closes.

My question is;

When this form closes, I want the data that is inside of the datagridview in the main form to refresh, how can I call that function on the main form from the edit form.

Keep in mind that I already have a reload function, let's say it's called refreshData();.

like image 813
AlbA Avatar asked Mar 18 '26 11:03

AlbA


1 Answers

if you open the edit form as a modal window, the ShowDialog() call is blocking, so if you put the refreshData call after that it will execute after the edit form is closed:

var editForm = new EditForm(...);
var result = editForm.ShowDialog();
if (result == DialogResult.OK)
{
    refreshData(); 
}
like image 89
Z.D. Avatar answered Mar 20 '26 02:03

Z.D.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!