private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e) { List <PatientModel> patients = new List <PatientModel>(); int PatientId = 0; ClearPatientData(); dataGridView2.DefaultCellStyle.SelectionBackColor = SystemColors.ControlDarkDark; dataGridView2.DefaultCellStyle.SelectionForeColor = Color.White; if (e.RowIndex != -1) { PatientId = Convert.ToInt32(dataGridView2.Rows[e.RowIndex].Cells[6].Value.ToString()); var patient = patientService.GetPatientById(PatientId); patients.Add(patient); ShowPatientData(patients); } }