一开始就运行一个表单 [英] Run a form at the start

查看:91
本文介绍了一开始就运行一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我的应用程序中有不同的表单,我想在应用程序开头运行一个特定的表单我该怎么办?

我做了一些研究,但我没有发现。



谢谢。



我是什么尝试过:



我尝试通过这个来修改progam.cs文件

Application.Run(new Form5( ));

但它不起作用。

Hello,
I have different forms in my application and I want to run a specific form at the beginning of the application how could I do it ?
I did some researches but I didn't find out.

Thank you.

What I have tried:

I tried to modify the progam.cs file by putting this
Application.Run(new Form5());
But it doesn't work.

推荐答案

是的。

当你使用Application.Run使用表单实例,它显示表单,并在表单关闭时返回 - 因此更改您创建的表单作为传递给方法更改哪个表单是您的主表单。

它不做的是显示一个表格并立即返回,这样你就可以显示第二个表格。

如果你试图显示类似的闪屏,那么单独留下Applicatio.Run,​​然后使用Form.Show在主窗体的控制器中打开启动窗体。



如果这不是你要做的事情,那么你需要提供更多的信息,因为Applciation.Run肯定适合我!
Yes it does.
When you use Application.Run with a form instance, it displays the form, and returns when the form is closed - so changing the form you create as pass to the method changes which form is your "main" form.
What it doesn't do is show a form and return immediately so you can display a second form.
If you are trying to show a splash screen of similar, then leave Applicatio.Run alone, and open the splash form in the contrustor of your main form using Form.Show.

If that isn't what you are trying to do, then you need to provide more information, because Applciation.Run certainly works for me!


Application.Run应该写在Main()方法的Program.cs中。下面给出的示例代码 -

Application.Run should be written in the Program.cs in the Main() method. Sample code given below -
[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new frmLogin());
}


这篇关于一开始就运行一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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