在C#中创建新表单 [英] create new form in C#

查看:82
本文介绍了在C#中创建新表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能通过点击buttem来制作新表格。怎么做?

I cant make new form by click on buttem.How do it?

推荐答案

试试:

Try:
private void myButton_Click(object sender, EventArgs e)
    {
    MyNewForm f = new MyNewForm();
    f.Show();
    }


正如OriginalGriff指出的那样,这里有一个WinForms应用程序的标准模型,由Visual Studio自动:在Program.cs文件中启动Main表单;通常该文件将如下所示:
As OriginalGriff points out to you, here, there is a "Standard Model" for a WinForms Application, created by Visual Studio "automatically:" a "Main" Form is launched in the Program.cs file; typically that file will look like this:
static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.Run(new Form1());
        }
    }

在应用程序启动后创建的任何表单将在主表单(Form1)关闭时自动关闭,并且将终止应用程序。



如果你的目标在运行时有多个独立的表单,那么你可以关闭它们中的任何一个,所有其他表格将保持打开/可用:这是一个应用程序的不同型号



是的,你可以在WinForms中实现一个多独立的表单应用程序,而imho,有一些类型的应用程序,我认为它是一个合适的策略:它是一个要求你修改应用程序启动方式的应用程序,并处理以下情况:当所有独立表格关闭时,您确保终止申请。



如果您的问题这里如何实现多个独立的表单应用程序,然后请修改你的原始问题,以便明确。

Any Forms created after the Application starts, will be closed automatically when the Main Form (Form1) is closed, and that will terminate the Application.

If your goal here is to have multiple independent Forms at run-time, where you can close any of them, and all other Forms will stay open/usable: that is a different model for an Application.

Yes, you can implement a multiple independent Form Application in WinForms, and, imho, there are some types of Applications where I think that it is an appropriate strategy: it's one that requires you to modify the way the Application starts, and handle the case where: when all "independent" Forms are closed, you make sure to terminate the Application.

If your question here is how to implement a multiple independent Forms Application, then please revise your original question so that is clear.

good luck, Bill


这篇关于在C#中创建新表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆