/// <summary> /// Fills the listbox with employees that are currently scheduled for that shift. /// </summary> /// <param name="toAddToShift"></param> private void AddEmployeeListToShift(List <Employee> toAddToShift) { dataGridViewScheduling.Rows.Clear(); dataGridViewScheduling.Refresh(); foreach (Employee e in toAddToShift) { int rowId = dataGridViewScheduling.Rows.Add(); DataGridViewRow row = dataGridViewScheduling.Rows[rowId]; row.Cells["id"].Value = e.Id; row.Cells["firstName"].Value = e.FirstName; row.Cells["surName"].Value = e.SurName; } foreach (DataGridViewRow row in dataGridViewScheduling.Rows) { int employeeid = Convert.ToInt32(row.Cells["id"].Value); int nrofshifts = employeeStorage.CheckNrOfShifts(employeeid, this.date.Date.ToString("yyyy-MM-dd")); if (nrofshifts > 2) { row.DefaultCellStyle.BackColor = Color.Red; } } }