Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Forms: create the main application after login, which form to run?

Tags:

c#

winforms

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 :)

like image 333
Petr Avatar asked Oct 27 '09 07:10

Petr


People also ask

Which method is used by a Windows application to execute the application?

The Main method calls Application. Run(context) to start the application given the ApplicationContext.

How do you set the starting from the first form to be displayed after running application of the project?

Click the File tab, and then under Help, click Options. Click Current Database. Under Application Options, in the Display Form list, select the form that you want to display when the database starts. Click OK, and then close and reopen the database to display the startup form.

How do I run a single instance of the application using Windows Forms?

" This feature is already built in to Windows Forms. Just go to the project properties and click the "Single Instance Application" checkbox. "


1 Answers

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.

like image 179
elder_george Avatar answered Oct 11 '22 11:10

elder_george