Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Multiple forms in one Csharp panel in one Windows Form panel?

Tags:

c#

.net

windows

I am building a kids learning application, where clicking on a button on panel, I want to show different forms in the same place of the panel. Can you please help with any walk-through or tutorial links?

like image 719
MSU Avatar asked Apr 08 '11 08:04

MSU


1 Answers

This question should have been posted on Stackoverflow website rather than 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;

You can add this code when you click on the specific button. Here each subform is added to the Panel as a Control. You should remove the subform from the panel's control list before adding another subform. For this ,it is better to remove,close and dispose the first one.

        ContainerPanel.Controls.Remove(activeform);
        activeform.Close();
        activeform.Dispose();
like image 81
Vimal Raj Avatar answered Sep 23 '22 19:09

Vimal Raj