在其他表格之前加载表格 [英] load a form before other forms

查看:61
本文介绍了在其他表格之前加载表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以为此提供帮助吗?
我有一个带有某些控件和代码的Windows窗体应用程序,可以运行....
当我运行我的项目时,form1将出现.确定.
现在,我创建了第二个表单,用于通过2个文本框和一个按钮来控制用户访问.

does anybody can help about this?
i had a windows form application with some controls and code to run...by the way.
when i run my project,the form1 will appear.ok.
And now i create second form for control user access with 2 text boxes and a button.
i want to run form2 before form1 when i run my projct.is it possible?

推荐答案

您需要从表单1的构造函数运行form2或更改什么?是您的项目的启动表单.构造函数不显示表单,需要发生各种事件,如果在构造函数中运行form2,它将首先运行.
You need to either run form2 from the constructor of form 1, or change what is the startup form for your project. The constructor does not show the form, various events need to occur, and if you run form2 in the constructor, it will run first.


在program.cs中,更改Application.Run( ...).因此,您可以在入口点[static void Main()]
中处理启动表单.
In program.cs, change the Application.Run(...). So you can handle your startup form in entry point [static void Main()]

[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());//here you change your form
}



希望有帮助.
欢呼



Hope this help.
cheers


就这样..
this is just as it..
public Form1()
{
    InitializeComponent();
    Application.Run(new Form2());
}


这篇关于在其他表格之前加载表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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