private void button3_Click(object sender, EventArgs e) { DriveForm _form = new DriveForm(); if (_form.ShowDialog() == DialogResult.OK) { CarDriveInfo _drive = new CarDriveInfo(); _drive.DriveID = _form.DriveID; _drive.CarID = _newCar.CarID; _drive.DriveName = _form.DriveName; _listCaDrive.Add(_drive); carDriveListBindingSource.DataSource = null; carDriveListBindingSource.DataSource = _listCaDrive; } }
private void button4_Click(object sender, EventArgs e) { int driveID = (int)carDriveListDataGridView.SelectedRows[0].Cells[0].Value; for (int i = _listCaDrive.Count - 1; i >= 0; i--) { if (_listCaDrive[i].CarDriveID == driveID) { _listCaDrive.RemoveAt(i); break; } } CarDriveInfo.DeleteCarDrive(driveID); carDriveListBindingSource.DataSource = null; carDriveListBindingSource.DataSource = _listCaDrive; }