Enable a button after entering password

-1

I need some help, but I do not know how to do this code.

I have a form and in this form I have a button that deletes in a SQL table, I want to make the button disabled and to enable it I want to make the user type a password.

Follow the code of the button that calls the form to enter the password.

private void btnExcluir_Click(object sender, EventArgs e)
{
    frmExclusao excluir = new frmExclusao(txtID.Text);
    excluir.Show();
}

follows the code of the password form.

private void btn_Ok_Click(object sender, EventArgs e)
{
    if (MessageBox.Show("Confirma a exclusão do cadastro", "Atenção", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
    {
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "DELETE FROM tbl_amostra WHERE ID = '" + txtID.Text + "'";
        cmd.Connection = conex;

        conex.Open();
        cmd.ExecuteNonQuery();
        conex.Close();
    }
    
asked by anonymous 26.06.2017 / 16:55

1 answer

3

Understanding that your project is winform when you speak in "I have a Form", use the TextChanged event of the TextBox:

private void textBox1_TextChanged(object sender, EventArgs e)
{
    ButtonDelete.Enable = (textBox1.Text == "1234");
}
    
26.06.2017 / 17:42