问题
I am displaying some data in datagridview whose datasource is a datatable.
For DateTime column, I want to use datetimepicker control to edit the value. So I tried the following code found in this link. https://msdn.microsoft.com/en-us/library/7tas5c80
After assigning the custom cell template to the DateTime column, datagridview is not invalidating immediately.
Here is the code I tried
dataGridView1.DataSource = dataTable;
CalendarCell cell = new CalendarCell();
this.dataGridView1.Columns["DATE"].CellTemplate = cell;
this.dataGridView1.Invalidate();
When I sort any column in datagridview. Then the custom template works.
I tried this also, still it is not working.
dataGridView1.InvalidateColumn(2);
How do I tell datagridview to invalidate immediately so that custom template works properly without the need of sorting the column?
来源:https://stackoverflow.com/questions/34550178/c-custom-celltemplate-is-not-invalidating-in-datagridview