如何在一个Windows窗体面板采用多种形式于一体Csharp的面板?面板、窗体、多种、形式

2023-09-04 02:00:22 作者:▍我的世界不能没有你

我建立一个孩子学习的应用程序,在点击一个按钮面板,我要显示在面板的同一个地方不同的形式。能否请您帮助任何演练或教程链接?

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?

推荐答案

这个问题应该被公布在网站上#1,而不是在这里。

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;

您可以添加此code,当你点击特定的按钮。 在这里,每个子窗体添加到面板作为对照。你应该添加其他窗体之前,请从面板的控制列表子窗体。对于这一点,最好是去掉,关闭和处置的第一个。

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();