Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ScheduleItemForm newScheduleForm = new ScheduleItemForm();

            if (newScheduleForm.ShowDialog() == DialogResult.OK)
            {
                // add this schedule to data grid
                Schedule schedule = newScheduleForm.Schedule;
                int      index    = dgrSchedules.Rows.Add();
                dgrSchedules[indexColumn.Name, index].Value       = index + 1;
                dgrSchedules[projectFileColumn.Name, index].Value = schedule.ProjectFile;
                dgrSchedules[editColumn.Name, index].Value        = "Edit";
                dgrSchedules[deleteColumn.Name, index].Value      = "Delete";
                dgrSchedules.Rows[index].Tag = schedule;
            }

            SaveSchedules();
        }
Ejemplo n.º 2
0
        private void dgrSchedules_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == deleteColumn.Index)
            {
                dgrSchedules.Rows.RemoveAt(e.RowIndex);
            }
            if (e.ColumnIndex == editColumn.Index)
            {
                Schedule         schedule     = (Schedule)dgrSchedules.Rows[e.RowIndex].Tag;
                ScheduleItemForm scheduleForm = new ScheduleItemForm();
                scheduleForm.Schedule = schedule;
                if (scheduleForm.ShowDialog() == DialogResult.OK)
                {
                    // update grid item
                    int index = e.RowIndex;
                    dgrSchedules[projectFileColumn.Name, index].Value = scheduleForm.Schedule.ProjectFile;
                    dgrSchedules.Rows[index].Tag = scheduleForm.Schedule;

                    SaveSchedules();
                }
            }
        }