private void FillGUIsporen() { bc.Update(); int rowCounter = 0; int cellCounter = 0; int testCounter = 0; foreach (Spoor spoor in bc.Sporen) { foreach (Sector sector in spoor.Sectoren) { if (sector.Status == SectorStatus.bezet) { if (sector.Tram != null) { dgvBeheer.Rows[rowCounter].Cells[cellCounter].Value = sector.Tram.TramNummer; rowCounter++; testCounter++; } else { dgvBeheer.Rows[rowCounter].Cells[cellCounter].Value = ""; rowCounter++; testCounter++; } } else { dgvBeheer.Rows[rowCounter].Cells[cellCounter].Value = ""; rowCounter++; testCounter++; } } cellCounter++; rowCounter = 0; } int rowCounterIU = 0; //int cellCounterIU = 0; dgvInEnUitrijsysteem.Rows.Clear(); foreach (Spoor spoor in bc.Sporen) { foreach (Sector sector in spoor.Sectoren) { if (sector.Status == SectorStatus.bezet && sector.Tram != null) { dgvInEnUitrijsysteem.Rows.Add(); dgvInEnUitrijsysteem.Rows[rowCounterIU].Cells[0].Value = sector.Tram.TramNummer; //TODO: nullreference, tram bestaat soms niet meer bij sommige sectoren. dgvInEnUitrijsysteem.Rows[rowCounterIU].Cells[1].Value = spoor.SpoorNummer; dgvInEnUitrijsysteem.Rows[rowCounterIU].Cells[2].Value = sector.Id; dgvInEnUitrijsysteem.Rows[rowCounterIU].Cells[3].Value = sector.Tram.Status; dgvInEnUitrijsysteem.Rows[rowCounterIU].Cells[4].Value = sector.Tram.VertrekTijd; rowCounterIU++; } } } }