private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; string[] valores = new string[e.ColumnIndex]; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { for (int i = 0; i < e.ColumnIndex; i++) { valores[i] = dataGridView1.Rows[e.RowIndex].Cells[i].Value.ToString(); } if (criterioABM == "baja") { BajaHabitacion levantarBaja = new BajaHabitacion(valores, conexion); this.Close(); levantarBaja.Show(); } else { ModifHabitacion levantarModif = new ModifHabitacion(valores, conexion); this.Close(); levantarModif.Show(); } } }