Autocompletion of the row in the datagridwier

0

Good afternoon. I need a help, I have a datagridwier and I have a column where I type a code for a product. Now I need that when the user enters the code of a product in the cell of the code column to enter the enter it fill the fields field and also the batch combobox with data from a select that I bring from the database. How can I do this?

Below is the screen of my datagridwier

SqlConnectionconnection=newSqlConnection(Properties.Settings.Default.DADOSADVConnectionString);        SqlCommandcommand=null;        publicfrmSolicitationAmostraPic()        {            InitializeComponent();        }

privatevoidlbl_email_Click(objectsender,EventArgse){}privatevoidbtn_ok_Click(objectsender,EventArgse){if(txt_codcli.Text!="")
        {

            SqlCommand comando = new SqlCommand(@"SELECT 
                                 SA.A1_NREDUZ AS CLIENTE, 
                                 +'(' + SA.A1_DDD + ')' + ' ' + SA.A1_TEL AS TELEFONE, 
                                 SA.A1_CEP AS CEP,
                                 SA.A1_END AS ENDERECO,
                                 SA.A1_BAIRRO AS BAIRRO,
                                 SA.A1_MUN AS CIDADE,
                                 SA.A1_EST AS ESTADO,
                                 CONVERT(VARCHAR(10), CAST(SA.A1_DTNASC AS DATE), 103) AS DATA
                            FROM SA1010 AS SA
                            WHERE SA.A1_COD = '" + txt_codcli.Text + "'", conex);
            comando.CommandType = CommandType.Text;
            conex.Open();
            SqlDataReader dr = comando.ExecuteReader();
            while (dr.Read())
            {
                txt_cliente.Text          = dr["CLIENTE"].ToString();
                txt_telefone.Text         = dr["TELEFONE"].ToString();
                txt_cep.Text              = dr["CEP"].ToString();
                txt_endereco.Text         = dr["ENDERECO"].ToString();
                txt_bairro.Text           = dr["BAIRRO"].ToString();
                txt_cidade.Text           = dr["CIDADE"].ToString();
                txt_uf.Text               = dr["ESTADO"].ToString();
                txt_dtcadastro.Text       = dr["DATA"].ToString();
            }
            conex.Close();
        }
        else
        {
            MessageBox.Show("Código do cliente invalido, por favor digitar um código de clinete válido");
            return;
        }
    }
}

}

    
asked by anonymous 06.09.2017 / 19:33

1 answer

0

Good afternoon, I think if you put the code part would help a lot, but I have a similar project, but I feed the Grid with an Array that I get from a Webservices, I'll put the code below.

         // o Registro contem dada dado concatenado e separado por ";"   
        for (int i = 0; i < registros; i++)
        {
            dataGridPermissoes.Rows.Add();

            var metadadoscort = ListRegistros[i + 1];
            var Listametadados = metadadoscort.Split(';');

            var permissao = "";
            if (Listametadados[10].Equals("M"))
            {
                permissao = "Modificar";
            }
            else if (Listametadados[10].Equals("R"))
            {
                permissao = "Remover";
            }
            else
            {
                permissao = "Leitura";
            }
             // Em vez de vc colocar "Listametadados[]" vc vai colocar o campos da tabela.
            dataGridPermissoes.Rows[i].Cells[0].Value = Listametadados[2];
            dataGridPermissoes.Rows[i].Cells[1].Value = Listametadados[4];
            dataGridPermissoes.Rows[i].Cells[2].Value = Listametadados[6];
            dataGridPermissoes.Rows[i].Cells[3].Value = Listametadados[8];
            dataGridPermissoes.Rows[i].Cells[4].Value = permissao;
        }
    
06.09.2017 / 20:26