Alex Silveira Amaral Posted February 12, 2020 at 01:58 AM Report Share #617315 Posted February 12, 2020 at 01:58 AM Em um Form1 tem um botão para pesquisar que abre um outro Form2 com um campo de pesquisa. Após preencher ou não esse campo, o resultado aparece numa DataGridView. Então escolhe a linha e os dados supostamente iriam preencher os TextBox do Form1. Porém quando passo o DataGridView como parâmetro de um método, os TextBox não se alteram. Irei deixar aqui o código do método que supostamente teria de preencher os TextBox: 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; } Aqui o mesmo código, porém eu coloquei um Console.WriteLine para comprovar que o parâmetro não está sem valores ou nulo. 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; } A saída desse Console.WriteLine está mostrando corretamente, somente os TextBox que não alteram seu conteúdo. Link to comment Share on other sites More sharing options...
M6 Posted February 17, 2020 at 09:13 AM Report Share #617365 Posted February 17, 2020 at 09:13 AM Faz debug e verifica, após a atribuição de um valor a uma caixa de texto, qual o valor que a mesma tem. Pode dar-se o caso de estares a limpar as caixas de texto num outro evento se te aperceberes. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now