c# - FormClose Event handler when form wasn't opened from parent -
i have many instances in program in main form1, call form2 , run event when form2 closes using formcloseeventhandler. updates data on form1.
however, need form1 run formclose event handler different form3 launched in part of program, not form1.
how achievable? thought of having timer run every 10 seconds on form1 public flag set form3 formclose event, isn't elegant soution.
while have no idea want , why using pattern, here solution satisfies need:
create method in form1
:
public void form3_formclosed(object sender, formclosedeventargs e) { messagebox.show("form 3 closed"); }
in load
event of form3
can this:
var f1 = application.openforms.oftype<form1>().firstordefault(); if(f1 !=null) this.formclosed += f1.form3_formclosed;
Comments
Post a Comment