Example #1
0
        public static void TasksToDataGridView(List <Task> lists, DataGridView dgv)
        {
            dgv.DataSource = null;
            dgv.Rows.Clear();

            CustomDataGridView.StartupDesign(dgv);
            for (int i = 0; i < lists.Count; i++)
            {
                int n = dgv.Rows.Add();
                dgv.Rows[n].Cells[0].Value = lists[i].Id;
                dgv.Rows[n].Cells[1].Value = lists[i].DateTime;
                dgv.Rows[n].Cells[2].Value = lists[i].TimeSpan;
                dgv.Rows[n].Cells[3].Value = lists[i].Description;

                if (lists[i].IdPriority.ToString() == ((int)PriorityModel.HIGH).ToString())
                {
                    dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
                }

                else if (lists[i].IdPriority.ToString() == ((int)PriorityModel.MEDIUM).ToString())
                {
                    dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Orange;
                }
                else
                {
                    dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Blue;
                }
            }
        }