This question should be posted on the Stackoverflow website, not here.
But you can use this approach to handle the case.
subForm = new SubFormYouWantToLoad(); subForm.TopLevel = false; subForm.FormBorderStyle = FormBorderStyle.None; ContainerPanel.Controls.Add(subForm , 0, 1); subForm .Visible = true;
This code can be added when you click on a specific button. Here, each subform is added to the panel as a control. You must remove the subform from the panel control list before adding another subform. To do this, it is better to delete, close and delete the first.
ContainerPanel.Controls.Remove(activeform); activeform.Close(); activeform.Dispose();
source share