Login Form

B

BobRoyAce

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.
 
J

Joanna Carter [TeamB]

"BobRoyAce" <[email protected]> a écrit dans le message de (e-mail address removed)...

|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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top