private void penjualan_btn_Click(object sender, EventArgs e) { if (penjualanPage == null) { penjualanPage = new adpenjualan(); //Create form if not created penjualanPage.FormClosed += penjualanPage_FormClosed; //Add eventhandler to cleanup after form closes InitializeComponent(); penjualanPage.Show(this); //Show Form assigning this form as the forms owner } }
void penjualanPage_FormClosed(object sender, FormClosedEventArgs e) { penjualanPage = null; Show(); }