示例#1
0
        private void LoadDetailsGrid()
        {
            DataTable detailsDataTable = new DataTable();

            detailsDataTable.Columns.Add(Columns.Position, typeof(byte));
            detailsDataTable.Columns.Add(Columns.PositionChange, typeof(Image));
            detailsDataTable.Columns.Add(Columns.TeamName, typeof(string));
            detailsDataTable.Columns.Add(Columns.Matches, typeof(byte));
            detailsDataTable.Columns.Add(Columns.Won, typeof(byte));
            detailsDataTable.Columns.Add(Columns.Draw, typeof(byte));
            detailsDataTable.Columns.Add(Columns.Lost, typeof(byte));
            detailsDataTable.Columns.Add(Columns.GoalsFor, typeof(int));
            detailsDataTable.Columns.Add(Columns.GoalsAgainst, typeof(int));
            detailsDataTable.Columns.Add(Columns.GoalDifference, typeof(int));
            detailsDataTable.Columns.Add(Columns.Points, typeof(byte));
            detailsDataTable.Columns.Add(Columns.TeamID, typeof(uint));

            foreach (HTEntities.LeagueDetails.Team team in leagueDetails.teamField)
            {
                DataRow newDataRow = detailsDataTable.NewRow();

                newDataRow[Columns.Position]       = team.positionField;
                newDataRow[Columns.PositionChange] = GenericFunctions.GetPositionChange(team.positionChangeField);
                newDataRow[Columns.TeamName]       = team.teamNameField;
                newDataRow[Columns.Matches]        = team.matchesField;
                newDataRow[Columns.Won]            = 0;
                newDataRow[Columns.Draw]           = 0;
                newDataRow[Columns.Lost]           = 0;
                newDataRow[Columns.GoalsFor]       = team.goalsForField;
                newDataRow[Columns.GoalsAgainst]   = team.goalsAgainstField;
                newDataRow[Columns.GoalDifference] = team.goalsForField - team.goalsAgainstField;
                newDataRow[Columns.Points]         = team.pointsField;
                newDataRow[Columns.TeamID]         = team.teamIdField;

                detailsDataTable.Rows.Add(newDataRow);
            }

            dataGridViewPositions.DataSource = detailsDataTable;
        }