In VB.NET there is an option to add a Splash Screen when you click Add New Window but when I do that with C#, I can't find any thing.
so
How I开发者_JS百科 can add a Splash Screen in C#?
(I'm on my Mac now so I may be a bit rusty...)
You need to open up your project preferences.
Project -> Preferences
In the first tab, select there is a dropdown menu called "Startup Object". The default is Form1.csYou should be able to change that to a splash screen window.
In Visual Studio 2010, this is really easy. Simply add an image to your Solution, then right-click on the image, and set it's Build Action to "SplashScreen".
No coding required!
Add a reference to Microsoft.VisualBasic. Then write the following code in 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();
}
}
}
精彩评论