C# Make Form1 Do An Action After Form2 is Closed -
i'm new c# , i've been reading documentation , old questions, can't find figure out how following.
i have 2 forms, form1 , form2.
form1 contains datagridview content file. button on form1 opens form2, user can come in info in textboxes. user clicks button on form2 adds new content file. works fine.
now, there's exit button on form2. want when user exits form2, form1 phone call method reload datagridview it's updated. how phone call method automatically when form2 closed?
thank you, help appreciated!
if user doesn't have interact form1
while form2
open, show sec form modal dialog, stops execution of code in first form, , update grid after displaying sec form.
using (var newfrm = new form2()) { newfrm.showdialog(); // execution of form1 stops until form2 closed } // read file , update datagridview (this line executes when form2 closed)
alternatively, subscribe form2's closed
event execute code when it's closed:
var newfrm = new form2(); newfrm.closed += delegate { // read file , update datagridview }; newfrm.show();
c#
No comments:
Post a Comment