Hi,
I created an app. I want a splash screen to be displayed in the beginning for 3 sec whenever I execute my program.
Suggest me a way!

Recommended Answers

All 3 Replies

Create a form, play with the different 'BorderStyle' properties to make it splash screen esque, then have this form shown in Program.cs instead of your main form (probably called Form1). In this form, have some sort of timer that controls how long it displays for, then when the timer elapses have it create and show your main form and call Hide() on your splash screen's form.

It is also a good idea to load your main form while the splash screen is showing. To do this, have your main form loading during the splash screen, then call Show() on it when the timer elapses. Doing this effectively requires a bit of multithreading though.

Is it possible without multi threading?

Create it as a login form (in same way):

static class Program
{  
    [STAThread]
    static void Main()
    {   
        using (Splash splash = new Splash())
        {
            splash.StartPosition = FormStartPosition.CenterScreen;
            if (splash.ShowDialog() == DialogResult.OK) 
            {      
                 Application.Run(new Form1()); 
            }
        }
    }
}



//inside Splash form do:
//use some Timer or something, and after some time call this method:
private void StopSplashScreen()
{       
     this.DialogResult = DialogResult.OK; //this will exit login and start Form1
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.