Open form on startup and bring it to front

Lanc1988

Contributor
Joined
Nov 27, 2003
Messages
508
Oh my main form's load event I have it open a form (form2), so in my main form's load event I have:

Dim form2 As New form2
form2.Show()

It opens it, but it has my main form on top of it, is there a way to make form2 come to the front?
 
This is one way to do it, but I am sure there are other ways...
Code:
_
   static class Program
    {
        [STAThread]
        static void Main()
        {
            Form1 form1 = new Form1();
            Form2 form2 = new Form2();
            form1.Show();
            form2.Show();
            Application.Run(form1);
        }
    }

I think that one of the problems is that the Load event comes before the form is activated and shown, therefore, no matter what you put in the Load class, the form will be shown after.
 
Back
Top