Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I have create 2 form within my C# project.

form1 is named login.

form2 is named main.

 

login form is used to verify username and password.

once the username and password is verified, login form will terminate and call form2 to enter the main screen.

 

I am having trouble calling form2.

Anyone know how to do this within Visual Studio C++?

Edited by noodlesoup
  • Leaders
Posted

I personally wouldn't recommend this technique. It would probably work, but it prevents the login form from being properly disposed and might cause obscure errors or problems down the road.

 

Multiple forms like this should be managed with the Application class. The simplest way to do this would probably be to duplicate the Application.Run in your Main() and specify the second form. The login data should probably be stored in your Program class or passed on to your main form.

 

Your main should probably look something like this:

/// <summary>
/// The main entry point for the application.
/// </summary>
[sTAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
login loginForm = new login();
Application.Run(new loginForm());
// Place code to manage login data here
Application.Run(new main()); // (or whatever your main form's class is called)
}

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...