C# – Windows Forms: create the main application after login, which form to run

cwinforms

Using Windows Forms I would like to have a small login screen the user authorizes himself/herself through (say its Form1), so the main application (say its Form2) would be opened after login. But I suppose when I use Application.Run(Form1), after closing it the whole application closes.

Isn't there any other way except using invisible Form2?
Something like run Form2 on demand and close originally ran Form1? Hope it makes sense to you 🙂

Best Answer

Create an overload of System.Windows.Forms.ApplicationContext, create Form1 first and then Form2 in its constructor.

Use Application.Run overload that accepts ApplicationContext object.

Related Topic