Which form event should I use to pop up a login fo

2019-09-20 04:19发布

问题:

Before the user makes use of the main form, I want to pester them to enter their username, password, and siteNumber.

Should I invoke a ShowDialog on the login form from the Main form's Load(), Activated(), GotFocus(), or Validate() events? Or should I just invoke the login form from the main form's constructor?

This is a Windows CE app, and those are the only options I have, event-wise (there is no "Shown" event).

回答1:

Have you considered prompting via ShowDialog before you even get to the main form?

Put the code right in the Main() someplace before the Application.Run(new MainForm()).

Works fine, I've done this before.