I have a simple problem: I have a main form in win-forms/c#. It has a listbox bound to a database.
When I click a button a new form is created.
When I click a button on the child form, I want to call a method that exists in the main form, that updates the list box or alternatively when the child form closes, to call that function.
Is this possible??
Scenario 1: Call a method in Parent Form on click of button in child form.
Create an
Eventin Child Form. Raise that event on some Button Click etc. Subscribe to that event in your Parent Form and call the parent’s form method inside that.Scenario 2: Call a method in Parent Form when Child Form is closed.
Handle the
FormClosedorFormClosingevent of Child Form in the Parent form and call the parent’s form method inside that.