2
I’m doing a project for college, I created a GroupBox
and inside there’s RadioButton
, Label
, MaskedTexbox
and TextBox
. When I click the cancel button I did the cleaning of the MaskTexbox
and TextBox
and disable the Textbox
. It just cleans and had to repeat the code to clean follows 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 that also worked out but I don’t 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;
}
}
Read your text calmly, think you don’t know the details of the program. Do you think you can understand? The text doesn’t seem to make much sense. I couldn’t understand if you wanted something more than what you’re doing and if something was wrong. Also depending on what you really want this isolated stretch don’t help understand the problem. What I can say is that this section is clearing the data and is marking a radio button as turned on.
– Maniero