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 var id = (int)gvRecList.SelectedRows[0].Cells["id"].Value; //query database var car = _db.typesOfCars.FirstOrDefault(q => q.id == id); //launch with edit var addEditVehicle = new AddEditVehicle(car, this); addEditVehicle.MdiParent = this.MdiParent; addEditVehicle.Show(); } catch (Exception ex) { MessageBox.Show($"Error:{ex.Message}"); } }