private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { try { string IdVisibilidad = dataGridView2.CurrentRow.Cells[1].Value.ToString(); string Descripcion = dataGridView2.CurrentRow.Cells[2].Value.ToString(); string Grado = dataGridView2.CurrentRow.Cells[3].Value.ToString(); string Porcentaje = dataGridView2.CurrentRow.Cells[4].Value.ToString(); string Costo = dataGridView2.CurrentRow.Cells[5].Value.ToString(); string Tieneenvio = dataGridView2.CurrentRow.Cells[6].Value.ToString(); string Costoenvio = dataGridView2.CurrentRow.Cells[7].Value.ToString(); Alta baja = new Alta(); baja.baja(IdVisibilidad, Descripcion, Grado, Porcentaje, Costo, Tieneenvio, Costoenvio); baja.Show(); this.Dispose(); } catch { MessageBox.Show("No se seleccionó registro para eliminar."); } } }
private void button1_Click(object sender, EventArgs e) { Alta alta = new Alta(); alta.Show(); }