...

View Full Version : Project with login form at the beginning in Visual C#



peniel
12-22-2011, 05:49 PM
I'm creating a project with a Login Form at the beggining, then goes straight to the Main Form after login. But the problem I'm facing is that my Main Form is showing with no controls on it, but when it's not running it has controls.
The Login Form runs perfectly and shows it's controls but after I click the login button to take me to the Main Form the Form appears with no controls at all. What might be the problem?

nanda.t
12-22-2011, 09:04 PM
Hi Peniel,

check the visible property of the controls.
Use F11, while debugging. It'll show the detailed execution flow

peniel
12-22-2011, 11:03 PM
Hey Nanda
All my controls are set to true on the visible property. This is what I did, I put this code in the program.cs file of my project.

static void Main()
{
Form fclsLoginDialog = new Form();
Form fclsMain = new Form();

if (fclsLoginDialog.ShowDialog() == DialogResult.OK)
{
Application.Run(new fclsMain());
}
else
{
Application.Exit();
}
}


then on my Login button click event this is how my code looks like

private void btnLogin_Click(object sender, EventArgs e)
{
String strUsername = "peniel";
String strPassword = "password";

if (this.txtUsername.Text == strUsername && this.txtPassword.Text == strPassword)
{
Form fclsMain = new Form();

fclsMain.Show();
this.Dispose();

}
else
MessageBox.Show("Please enter your correct Username and Password");
return;

}



But when i tried using the f11 key it seems like the code in the programs.cs file is not being executed when it comes to opening the fclsMain.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum