Following this example:
http://msdn.microsoft.com/en-us/library/7tas5c80.aspx
However, at run time, when I add rows to my DataGridView and they are displayed, the column containing the CalendarColumn is blank up until when I click on it. Then, as soon as I click anywhere else, the column goes blank again. So it’s only available to be seen at the exact moment when you’re interacting with it.
Any ideas what could be causing this?
EDIT: Only relevant portion of code. Rest is done through the designer.
private void LoadScheduleView()
{
// Get the keys
var scheduleNames = _schedules.Current.Keys;
// Get the current scheduled objects based on the keys (layoutnames).
foreach (var scheduleName in scheduleNames)
{
var schedule = _schedules.Current[scheduleName];
// Add the already existing schedule to the data grid view.
schedulesDataGrid.Rows.Add(schedule.Date, schedule.Layout, schedule.CloseAllWindows);
}
//schedulesDataGrid.Sort(schedulesDataGrid.Columns[0], ListSortDirection.Ascending);
DateTime scheduledTime = new DateTime();
var rowsToLoop = schedulesDataGrid.Rows;
foreach (DataGridViewRow row in rowsToLoop)
{
scheduledTime = (DateTime)row.Cells[0].Value;
if (scheduledTime < DateTime.Now)
{
schedulesDataGrid.Rows.Remove(row);
}
//This will happen in sorted list order, therefore the first time it's after DateTime.Now, it will be the next layout to launch.
else
{
var indexOfNextSchedule = schedulesDataGrid.Rows.IndexOf(row);
schedulesDataGrid.FirstDisplayedScrollingRowIndex = indexOfNextSchedule;
//schedulesDataGrid.Rows[indexOfNextSchedule].Selected = true;
break;
}
}
}
It seems as though the problem lay in the fact that the
CalendarCellwas being derived fromDataGridViewCelland notDataGridViewTextBoxCell. I’ll report back if I see that this causes any further issues…