What reference is missing for my Form fields to be filled with Datagridview information?

Asked

Viewed 21 times

0

I created a separate project to find out why information from any row in my table is not sent to the fields in my frmVisualizar_Cadastro. I discovered the error and now when I click on any row of my table, the fields of mine Test form are filled, but in my real project it does not happen that. They remain white. In the test project, I left everything in one form. In the actual project, I’m working with more than 1 form. How do I fill in the fields of this new form that opens when I click on any table row? Follow the project code:

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        try
        {
            DataTable dt = new DataTable();
            string strConn = @"Server = .\sqlexpress;Database = bdigreja; Integrated Security = SSPI;";
            SqlConnection conn = new SqlConnection(strConn);
            string wnome;
            wnome = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            SqlDataAdapter da = new SqlDataAdapter("Select nome,cpf,data_nasc,endereco,end_numero,complemento,bairro,cidade,uf,cep,celular,celular_dois,telefone,telefone_dois,genero,estado_civil,batismo,min_batismo,obreiro,cargo from tb_crentes where codigo = " + wnome, conn);
            da.Fill(dt);

            frmVisualizar_Cadastros frmVisualizar_Cadastros1 = new frmVisualizar_Cadastros();
            frmVisualizar_Cadastros1.ShowDialog();

            frmVisualizar_Cadastros1.txtNome3.Text = dt.Rows[0]["nome"].ToString();
         }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Deu ruim");
        }
  • Don’t get it, you have the routine in one form that wants to fill another form? How are you instantiating it?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.