【发布时间】:2010-04-04 15:01:13
【问题描述】:
在 VB.NET 中,当您单击“添加新窗口”时,有一个添加启动画面的选项,但是当我使用 C# 执行此操作时,我找不到任何东西。
所以
如何在 C# 中添加启动画面?
【问题讨论】:
标签: c# visual-studio-2008
在 VB.NET 中,当您单击“添加新窗口”时,有一个添加启动画面的选项,但是当我使用 C# 执行此操作时,我找不到任何东西。
所以
如何在 C# 中添加启动画面?
【问题讨论】:
标签: c# visual-studio-2008
(我现在在我的 Mac 上,所以我可能有点生疏......)
您需要打开您的项目首选项。
项目 -> 首选项
在第一个选项卡中,选择一个名为“启动对象”的下拉菜单。默认是 Form1.cs 你应该可以把它改成闪屏窗口。
【讨论】:
在 Visual Studio 2010 中,这非常简单。只需将图像添加到您的解决方案,然后右键单击图像,并将其构建操作设置为“SplashScreen”。
无需编码!
【讨论】:
添加对 Microsoft.VisualBasic 的引用。然后在Program.cs中编写如下代码
static class Program
{
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
new MyApp().Run(args);
}
public class MyApp : WindowsFormsApplicationBase
{
protected override void OnCreateSplashScreen()
{
this.SplashScreen = new MySplashScreen();
}
protected override void OnCreateMainForm()
{
// Do stuff that requires time
System.Threading.Thread.Sleep(5000);
// Create the main form and the splash screen
// will automatically close at the end of the method
this.MainForm = new MyMainForm();
}
}
}
【讨论】: