Reputation: 197
I wanna know if it is possible to call a non-static function from e.g. Form1 on Form2 close event.
Here is where I open the second form:
private void listaclientes_listbox_DoubleClick(object sender, EventArgs e)
{
EditarCliente ed = new EditarCliente(listaclientes_listbox.SelectedIndex, bib);
ed.Show();
}
And this is the method I wanna call, which bellongs to the first form:
private void loadlista_clientes()
{
listaclientes_listbox.Items.Clear();
for (int p = 0; p < bib.index; p++)
listaclientes_listbox.Items.Add(bib.ListaCliente[p].nome + " - CC: " + bib.ListaCliente[p].cc);
}
Upvotes: 0
Views: 144
Reputation: 10804
Easiest way to do this is to add a handler for the FormClosed event (not sure if you are using WPF or WinForms)
So something like this
private void listaclientes_listbox_DoubleClick(object sender, EventArgs e)
{
EditarCliente ed = new EditarCliente(listaclientes_listbox.SelectedIndex, bib);
ed.Closed += (o,e) => { loadlista_clientes(); }
ed.Show();
}
Upvotes: 2