How to set which of the forms appear first

前端 未结 4 1788
北恋
北恋 2020-12-29 12:35

I\'m a beginner c# programmer, and i\'m getting familiar with the Windows Forms App. I have 2 forms and i\'m trying to understand how to set one of them to be the first one

相关标签:
4条回答
  • 2020-12-29 13:03

    In your visual studi, when ever you open a project by default program.cs will open.

       static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    

    you can see above Application.Run(new Form1());

    whatever your form name is type there, then whenever you are starting first this form will run

    0 讨论(0)
  • 2020-12-29 13:09

    In Program.cs, you will see the following line of code

    Application.Run(new Form1()); This line shows Form1. You can change it to do whatever you want.

    0 讨论(0)
  • 2020-12-29 13:10

    Write in Program.cs

    Application.Run(new YourMainForm()); 
    
    0 讨论(0)
  • 2020-12-29 13:12

    In Program.cs, you will see the following line of code

    Application.Run(new Form1());
    

    This line shows Form1.
    You can change it to do whatever you want.

    0 讨论(0)
提交回复
热议问题