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();
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.
Application.Exit(0);
SetVisibilityCore
and call it inside MainForm_Load
.