So far, this is the button click event to instantiate the other form of the button. It pops up the other form—but the first form is still in the background, and after closing the second one, the first also closes and stops running. Any advice?
private void BtnInventoryClickEvent(object sender, EventArgs e)
{
frmInv viewInve = new frmInv();
viewInve.ShowDialog();
this.Hide();
}
CodePudding user response:
Your code seems to (unintentonally) stop at the .ShowDialog() line:
// your first line:
frmInv viewInve = new frmInv(); // here the new frmInv is getting created successfully
viewInve.ShowDialog(); // but here the code would stop
// because ShowDialog() produces a so called "modal window" AKA "dialog"
// so that the next line does not run before the current user would
// interactively close frmInv
// And then the next line hides your current Form:
this.Hide();