Pass data from a DataGridView to another DataGridView in the same form and modify the amount when passing the row

0

I need to send the information of a DataGridView to another and have the amount modified by sending it. For example, if the first DataGridView has an amount of 2 when passing it to the new grid, only 1 remains and if I add it again that product will be deleted because it is empty.

I can now pass the information, but I can not change the amount.

Example:

This is my code:

private void btnAgregar_Click(object sender, EventArgs e)
{
    if (dvgNuevo.Columns.Count == 0)
    {
        foreach (DataGridViewColumn item in dvgVistaInsumos.Columns)
        {
            dvgNuevo.Columns.Add(item.Name, item.HeaderText);
        }
        dvgNuevo.Rows.Clear();
        dvgNuevo.DataSource = null;
    }

    dvgNuevo.Rows.Add(new DataGridViewRow());

    int i;
    foreach (DataGridViewRow item in dvgVistaInsumos.SelectedRows)
    {
        i = 0;
        foreach (DataGridViewCell cel in dvgVistaInsumos.SelectedCells)
        {
            dvgNuevo.Rows[dvgNuevo.Rows.Count - 1].Cells[i].Value = cel.Value;
            i++;
        }
    }        
}
    
asked by Antonio 07.11.2018 в 18:07
source

0 answers