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
  • 249,864
  • 45
  • 407
  • 398
Saleh
  • 2,657
  • 12
  • 46
  • 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
  • 51,770
  • 36
  • 127
  • 149
Mike Gledhill
  • 27,846
  • 7
  • 149
  • 159
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
  • 57,511
  • 78
  • 272
  • 425
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,816
  • 3
  • 20
  • 36
  • @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