I'm doing a project for college, I created a GroupBox
and inside it has RadioButton
, Label
, MaskedTexbox
and TextBox
. When I click the cancel button I cleaned MaskTexbox
and TextBox
and disabled Textbox
. It just cleaned and had to repeat the code to clean it goes below.
private void toolStripButtonCancelar_Click(object sender, EventArgs e)
{
rdbAprovadoAberto.Enabled = false;
rdbReprovadoAberto.Enabled = false;
lblNomeUser.Text = "Sistema";
maskDataAprovReprov.Text = "";// limpa o campo MaskedTextBox
txtMotivoReprovaAberto.Text = "";// limpa o campo TextBox
this.txtMotivoReprovaAberto.Enabled = false;
// tenho que duplicar o código senão não limpa os campos e desabilita txtMotivoReprovaAberto
rdbAbertoAberto.Checked = true;
maskDataAprovReprov.Text = "";
txtMotivoReprovaAberto.Text = "";
txtMotivoReprovaAberto.Enabled = false;
}
And this also worked out more I do not know if it's good practices
private void toolStripButtonCancelar_Click(object sender, EventArgs e)
{
rdbAprovadoAberto.Enabled = false;
rdbReprovadoAberto.Enabled = false;
lblNomeUser.Text = "Sistema";
if (rdbAprovadoAberto.Checked)
{
maskDataAprovReprov.Text = "";
}
if (rdbReprovadoAberto.Checked)
{
maskDataAprovReprov.Text = "";
txtMotivoReprovaAberto.Text = "";
txtMotivoReprovaAberto.Enabled = false;
}
}