// changing active row in the table private void ScheduleView_RowEnter(object sender, DataGridViewCellEventArgs e) { // choose the row index of the selected row int rowIndex = e.RowIndex; // set active row variable to current row activeRow = rowIndex; // initialize form controls with data from the selected row // so it can be changed CommentaryBox.Text = DisplayData[rowIndex].Comment; if (DisplayData[rowIndex].StartTime.Date > DateTime.MinValue) { StartTimePicker.Value = DisplayData[rowIndex].StartTime; } else { StartTimePicker.Value = DateTime.Now - DateTime.Now.TimeOfDay; } if (DisplayData[rowIndex].EndTime.Date > DateTime.MinValue) { EndTimePicker.Value = DisplayData[rowIndex].EndTime; } else { EndTimePicker.Value = DateTime.Now - DateTime.Now.TimeOfDay; } EventBox.SelectedIndex = EventBox.FindStringExact(DisplayData[rowIndex].EventTypeName); }
// form load private void BasicScheduleForm_Load(object sender, EventArgs e) { WeekdayCombobox.DataSource = Enum.GetValues(typeof(DayEnum)); EventBox.DataSource = EventDisplayData; EventBox.DisplayMember = "EventTypeName"; EventBox.SelectedIndex = EventBox.FindStringExact(DisplayData[0].EventTypeName); }
// loader private void ScheduleForm_Load(object sender, EventArgs e) { DisplayData = OrganizerLibrary.GlobalConfig.Connections[0].GetEventsOfDay_All(DateTime.Now); DisplayData.Add(new EventModel()); ScheduleView.DataSource = DisplayData; EventBox.DataSource = EventDisplayData; EventBox.DisplayMember = "EventTypeName"; EventBox.SelectedIndex = EventBox.FindStringExact(DisplayData[0].EventTypeName); }