I have this form called MainForm.cs. When I click Enter The Progam button I display another form using the .ShowDialog() method.
In this new form called LoginBox.cs, I check if the entered credentials are valid and if they are I want my MainForm.cs to react with either a positive responde (the actual software form opens) or negative response a MessageBox alerting him of the failure.
It's a very simple use case, but I don't know how to solve this correctly and efficiently. Thank you.
private void button1_Click(object sender, EventArgs e)
{
LoginBox login = new LoginBox();
login.ShowDialog();
}
//And in the LoginBox.cs file:
private void button1_Click(object sender, EventArgs e)
{
if ((txtUser.Text == "admin") && (txtPassword.Text == "123"))
{
}
}