0
respostas

TextBox não recebe valor C#

Não estou conseguindo atribuir os valores aos TextBox. Quando faço um "Console.WriteLine" é mostrado o valor da célula do DataGridView, porém o TextBox não recebe o valor. Como poderia solucionar essa situação?

public void EditFuncionario(DataGridView dataGridPesqFunc)
        {
            DataGridViewRow row = dataGridPesqFunc.Rows[0];
            txtCod.Text = row.Cells["ID"].Value.ToString().Trim();
            txtNome.Text = row.Cells["Nome"].Value.ToString().Trim();
            txtCpf.Text = row.Cells["CPF"].Value.ToString().Trim();
            txtEmail.Text = row.Cells["Email"].Value.ToString().Trim();
            txtFixo.Text = row.Cells["Fixo"].Value.ToString().Trim();
            txtCel.Text = row.Cells["Celular"].Value.ToString().Trim();
            txtRua.Text = row.Cells["Rua"].Value.ToString().Trim();
            txtNumero.Text = row.Cells["Numero"].Value.ToString().Trim();
            txtBairro.Text = row.Cells["Bairro"].Value.ToString().Trim();
            txtComplemento.Text = row.Cells["Complemento"].Value.ToString().Trim();
            txtCidade.Text = row.Cells["Cidade"].Value.ToString().Trim();
            txtCep.Text = row.Cells["CEP"].Value.ToString().Trim();
            comboBoxEstados.SelectedItem = row.Cells["UF"].Value.ToString().Trim();
            btnAlterar.Enabled = true;
        }

Abaixo com o Console.WriteLine:

public void EditFuncionario(DataGridView dataGridPesqFunc)
        {
            DataGridViewRow row = dataGridPesqFunc.Rows[0];
            txtCod.Text = row.Cells["ID"].Value.ToString().Trim();
            Console.WriteLine("NOME = " + row.Cells["Nome"].Value.ToString().Trim());
            txtNome.Text = row.Cells["Nome"].Value.ToString().Trim();
            txtCpf.Text = row.Cells["CPF"].Value.ToString().Trim();
            txtEmail.Text = row.Cells["Email"].Value.ToString().Trim();
            txtFixo.Text = row.Cells["Fixo"].Value.ToString().Trim();
            txtCel.Text = row.Cells["Celular"].Value.ToString().Trim();
            txtRua.Text = row.Cells["Rua"].Value.ToString().Trim();
            txtNumero.Text = row.Cells["Numero"].Value.ToString().Trim();
            txtBairro.Text = row.Cells["Bairro"].Value.ToString().Trim();
            txtComplemento.Text = row.Cells["Complemento"].Value.ToString().Trim();
            txtCidade.Text = row.Cells["Cidade"].Value.ToString().Trim();
            txtCep.Text = row.Cells["CEP"].Value.ToString().Trim();
            comboBoxEstados.SelectedItem = row.Cells["UF"].Value.ToString().Trim();
            btnAlterar.Enabled = true;
        }

Aqui a saída: NOME = ALEXANDRE EUCLIDES