C# Opening a new form and closing the other one

前端 未结 5 535
深忆病人
深忆病人 2021-01-12 07:03

In my program I show a login form before the main form, once the program detects a successful login I use this:

MainForm Main = new MainForm();
Main.Show();
         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-12 08:02

    Change the main form to be MainForm, and when the application launches, in your MainForm_Load launch login form as a dialogbox, so they cannot access the main form.

    • If you need to be able to close the application from the login form, use Application.Exit(0);
    • If you don't want them to see the main form lookup and override SetVisibilityCore and call it inside MainForm_Load.

提交回复
热议问题