Main window appears behind other windows after splash screen

I have a Windows Forms Application with a splash screen. When I run the application the splash screen shows up fine, disappears and the main form for the application is loaded.

However, when I load the main form it appears beneath the Windows Explorer directory which contains the application. Here is a segment of code that runs the splash screen and then the main form.

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {        
        public Form1()
        {
            Thread t = new Thread(new ThreadStart(SplashStart));
            t.Start();
            Thread.Sleep(1500);
            InitializeComponent();
            t.Abort();
        }        
        public void SplashStart()
        {
            Application.Run(new SplashScreen());
        }
    }
}   

How can I get Form1 to show above all other windows?

Upvotes: 8

Views: 2887

Answers (2)

Dwedit
Dwedit

Reputation: 754

Use form.BringToFront() to put the form in front of everything else.

Upvotes: 3

Doug E Fresh
Doug E Fresh

Reputation: 840

Form1.Activate(); 

This should make it the focus and bring to front.

MSDN link: system windows forms form activate

Upvotes: 6

Related Questions