eltel2910
eltel2910

Reputation: 345

Give focus to form2

I have a program with two forms, but Form1 is opening up over Form2, which isn't good since you need to use Form2 first. How can you force focus to Form2 when the application runs?

Upvotes: 0

Views: 302

Answers (1)

Habib
Habib

Reputation: 223237

Use ShowDialog for Form2 instead of Show.

You can also use Application.OpenForms property to get the already opened form Form2 and then call its Focus method like:

if(Application.OpenForms["Form2"] != null)
   Application.OpenForms["Form2"].Focus();

Upvotes: 1

Related Questions