Hello,
I have a problem with passing information between forms in windows forms with C #, the problem is the following. I have a MAIN FORM, from this, I call the one SUB FORM, which happens to be the child's principal. The point is, I want the SUB FORM to pass me, or return some information back to the MAIN. It can be a Boolean value, list, anyway, I want to pass any value.
Example:
NO MAIN FORM:
private void buttonDiretorio_Click(object sender, EventArgs e)
{
Form Frm = new FormOpenDirectorySystem();
Frm.ShowDialog();
bypass = Frm.bypass;
if (bypass)
{
MessageBox.Show("O acesso foi concedido.", "Acesso liberado.", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (Directory.Exists("C:\Diretorio\"))
{
//abro o diretório
}
else MessageBox.Show("O diretório raiz do sistema não foi encontrado.", "Problema ao abrir o diretório raiz", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
ON THE SUB FORM THAT IS CALLED BY THE MAIN FORM:
public partial class FormOpenDirectorySystem : Form
{
public FormOpenDirectorySystem()
{
InitializeComponent();
}
public bool bypass = false;
private void buttonCancelar_Click(object sender, EventArgs e)
{
bypass = false;
this.Close();
}
private void buttonContinuar_Click(object sender, EventArgs e)
{
String password = txtBypass.Text;
if (password == "1q2w3e4r5t")
{
bypass = true;
this.Close();
}
else
{
bypass = false;
this.Close();
}
}
}
In my example, I am in the main form, and I call a new screen, where I will read a password / password / bypass, and I want this bypass to return TRUE if the "authentication" was successful , or FALSE if it was not successful.
Sincerely;