Como puedo iniciar un bloque de código donde indique guardar los registros actualizados después de hacer modificaciones directamente en un grid.
desde un botón "Guardar" indicar la instrucción.
El SaveChanges(); no me guarda los cambios realizados.
private void dgvProductos_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.dgvProductos.Rows[e.RowIndex].Selected = true;
this.rowIndex = e.RowIndex;
this.dgvProductos.CurrentCell = this.dgvProductos.Rows[e.RowIndex].Cells[1];
this.contextMenuStrip1.Show(this.dgvProductos, e.Location);
contextMenuStrip1.Show(Cursor.Position);
}
}
private void contextMenuStrip1_Click(object sender, EventArgs e)
{
ProductosEF _bdVentas = new ProductosEF();
if (MessageBox.Show("¿Desea eliminar permanente el producto?", "¡Advertencia!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
if (!this.dgvProductos.Rows[this.rowIndex].IsNewRow)
{
this.dgvProductos.Rows.RemoveAt(this.rowIndex);
}
}
_bdVentas.SaveChanges();
}