如何在C#中启动表格 [英] how to start up form in c#
问题描述
我有form1,form2,form3或更多,但是启动form1为何请帮助我
i have form1, form2,form3 or more but start up form1 why please help me
推荐答案
查看应用程序的入口点(通常是"Main
).它的行是:
Look at your application''s entry point (usually "Main
"). It has the line:
Application.Run(new Form1());
该应用程序的开始定义了您的主要形式.关闭主窗体时,整个应用程序都会退出(除非您处理FormClosing
事件以将其取消).
如果要显示其他形式,则需要……很好,请显示它们:
This start of application defines what is your main form. When you close a main form, the whole application quits (unless you handle FormClosing
event to cancel it).
If you want to show other forms, you need to… well, show them:
//pretty sloppy code:
Form newForm = new Form2();
newForm.Show();
//more accurate code:
Form mainForm = new Form1();
Application.Run(mainForm);
Form newForm = new Form2();
mainForm.AddOwnedForm(newForm);
newForm.ShowInTaskbar = false;
newForm.Show();
使表单归主表单所有会使它们一起激活,这有助于提高应用程序行为的完整性.这样,来自其他应用程序的任何窗口都不会在您的应用程序的窗体之间以Z顺序出现.在任务栏中不显示表单可以补充此行为.这样,只有主窗体代表任务栏上的整个应用程序.
请参阅: http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx [ ^ ].
Making a form owned by a main form makes them activate together, which help integrity if application behavior. In this way, no window from other application can appear in Z order between the forms of your application. Not showing a form in a task bar complements this behavior. In this way, only a main form represents whole application it the task bar.
See: http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx[^].
您可以更改它....
转到program cs
.
并进行如下更改:
解决方案资源管理器中的
You can change it....
Go toprogram cs
.
and change like as follows:
Application.Run(new Form2());
右键单击项目标题
转到属性
在其中一个菜单中
您会找到名为
的选项 ``startupobject''-默认情况下设置为``Form1''
您可以将其更改为您的要求
在控制台应用程序中非常有用
-尝试观察
in solution explorer
right click on project title
go to properties
in that one of the menu
u will find option called
''startupobject'' - by default it set ''Form1''
u can change it to ur requirement
which is very much useful in console applications
-try to observe it
这篇关于如何在C#中启动表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!