vb.net - Closing parent form when child form also closes -
aside main form have form, frmaddfixture, can open frmaddreport.
i'm trying close frmaddfixture when "no" selected msgbox, closes (successfully) me (frmaddreport). if "yes" selected frmaddfixture should stay open, does. can't close "no". i've tried adding own handler in detect when frmaddreport closing, couldn't working.
frmaddreport code (run after "submit" button has been clicked):
private sub showmsg() select case msgbox("do want add player report fixture?", msgboxstyle.question + msgboxstyle.yesno, "add further reports") case msgboxresult.yes isnewfixture = false me.close() case msgboxresult.no isnewfixture = true me.close() ''close frmaddfixture 'frmaddfixture.dispose() 'frmaddfixture.close() 'frmaddfixture.hide() end select end sub
attempted:
private sub frmaddreport_formclosed(byval sender object, byval e eventargs) handles mybase.formclosed frmaddfixture.dispose() end sub
here think trying do.
let's ignore message box moment , have 2 forms : form1
, form2
. want form2
colsed, form1
disposed (closed) well. i'ts pretty simeple :
public class form2 ' occurs when form2 closed (note event handler). private sub form2_formclosed(sender object, e eventargs) handles mybase.formclosed form1.dispose() end sub end class