private void btnAddCar_Click(object sender, EventArgs e) { var addEditVehicle = new AddEditVehicle(this); addEditVehicle.MdiParent = this.MdiParent; addEditVehicle.Show(); }
private void btnEditCar_Click(object sender, EventArgs e) { try { //get ID of selected row var id = (int)gvVehicleList.SelectedRows[0].Cells["Id"].Value; //query database for recoed var car = _db.TypeOfCars.FirstOrDefault(q => q.Id == id); //launch AddEditVehicle window with data var addEditVehicle = new AddEditVehicle(car, this); addEditVehicle.MdiParent = this.MdiParent; addEditVehicle.Show(); } catch (Exception ex) { MessageBox.Show($"EditError: {ex.Message}"); } }