按照这个例子:
http://msdn.microsoft.com/en-us/library/7tas5c80.aspx
但是,在运行时,当我向 DataGridView 添加行并显示它们时,包含 CalendarColumn 的列是空白的,直到我单击它。然后,只要我单击其他任何地方,该列就会再次变为空白。因此,只有在您与之交互的确切时刻才能看到它。
有什么想法可能导致这种情况吗?
编辑:只有代码的相关部分。休息是通过设计师完成的。
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;
}
}
}