5

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 can add a Splash Screen in C#?

Mark Rushakoff
  • 238,196
  • 44
  • 399
  • 395
Saleh
  • 2,587
  • 12
  • 42
  • 73

3 Answers3

3

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!

Setting a splash screen

Ben
  • 50,172
  • 36
  • 122
  • 141
Mike Gledhill
  • 25,874
  • 6
  • 141
  • 151
3

(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.

Moshe
  • 56,717
  • 76
  • 267
  • 423
2

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();
      }
   }  
} 
Alexandre Pepin
  • 1,797
  • 3
  • 18
  • 35
  • @Alaxandre - Code?! - There is a convenient way to do this without code. However, i do like the idea of being able to do things pragmatically, so +1. – Moshe Apr 04 '10 at 15:21