private void btn_eliminar_Click(object sender, EventArgs e) { String codi; Int32 selectedRowCount = dgv_bodega.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount > 0) { codi = Convert.ToString(dgv_bodega.CurrentRow.Cells[0].Value); negocio neg = new negocio(); neg.EliminarBodega(Convert.ToInt32(codi)); } else { MessageBox.Show("Debe seleccionar una fila"); } }