I have a login form that I want to show before the Main form loads. I
am currently showing it in the Main form's Load event. If ModalResult
of form does not return as DialogResult.OK, I call Me.Close for the
Main Form.

1) Is best place to show it in Main form's Load event?
2) Is calling Me.Close in Load event the best way to keep the Main form
from ever showing (i.e. quitting the application before it even
appears)?

If answer to either question above is No, please advise as to better
solution.

Re: Login Form by Joanna

Joanna
Sun Jun 11 02:18:18 CDT 2006

"BobRoyAce" <broy@omegasoftwareinc.com> a écrit dans le message de news:
1150000962.643030.123490@m38g2000cwc.googlegroups.com...

|I have a login form that I want to show before the Main form loads. I
| am currently showing it in the Main form's Load event. If ModalResult
| of form does not return as DialogResult.OK, I call Me.Close for the
| Main Form.
|
| 1) Is best place to show it in Main form's Load event?

No

| 2) Is calling Me.Close in Load event the best way to keep the Main form
| from ever showing (i.e. quitting the application before it even
| appears)?

No

| If answer to either question above is No, please advise as to better
| solution.

Don't create an instance of your main form class to start with; instead
create an instance of your login form class, react to it and then optionally
create an instance of you main form class.

Sorry, but I don't do VB, so code is in C#

static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
LoginForm login = new LoginForm();
login.ShowDialog();
if (login.DialogResult == DialogResult.OK)
{
Application.EnableVisualStyles();
Application.Run(new MainForm());
}
}
}

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer