I am new to C# and .NET programming. I want to design an application that opens up with a small login screen and when user presses the "Login" button, my program should close the login form and pass to a new form. How can I achieve this simple process?
Thanks.
This could be a solution;
In LoginForm;
public bool IsLoggedIn { get; private set;}
public void LoginButton_Click(object sender, EventArgs e)
{
IsLoggedIn = DoLogin();
if(IsLoggedIn)
{
this.Close()
}
else
{
DoSomethingElse();
}
}
In program.cs
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoginForm loginForm = new LoginForm();
Application.Run(loginForm);
if (loginForm.IsLoggedIn)
{
Application.Run(new OtherForm());
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With