Passing data from a gridview to another gridview

0

I have a datagridview1 that searches the database for the data and shows the information, I want it to click the add button it picks the selected row in the first datagridview1 and passes it to another datagridview2.

    
asked by anonymous 18.05.2017 / 21:49

1 answer

2

I just put an example List<string> , but the idea is this:

    List<string> Selecionados = new List<string>();
    private void buttonAdicionar_Click(object sender, EventArgs e)
    {
        if (dataGridView1.SelectedRows.Count >0)
        {
            string item = dataGridView1.SelectedRows[0].Cells["ColunaItem"].Value.ToString();
            //Adiciona outras propriedades, quantidades, etc...
            Selecionados.Add(item);
            //update no dataGridView2
        }
    }
    
18.05.2017 / 22:08