I put in a DateTimePicker into a DataGridView control just like in the
http://msdn.microsoft.com/en-us/library/7tas5c80.aspxarticle. The only problem is that when I try to insert another row, the DateTimePicker cell goes blank and clicking in the cell will generate an exception "Conversion from type 'DBNull' to type 'Date' is not valid." in the following routine:
Public Overrides Sub InitializeEditingControl(B
yVal rowIndex As Integer, _
ByVal initialFormattedValue As Object, _
ByVal dataGridViewCellStyle As DataGridViewCellStyle)
' Set the value of the editing control to the current cell value.
MyBase.InitializeEditingCo
ntrol(rowI
ndex, initialFormattedValue, dataGridViewCellStyle)
Dim ctl As CalendarEditingControl = CType(DataGridView.Editing
Control, CalendarEditingControl)
ctl.Value = CType(Me.Value, DateTime) '<--- ERROR OCCURS HERE
End Sub
The value is DBNull - the problem is that the Date cell is blanking out before the dataset row is updated (simply moving over to the next cell is somehow forcing the datagridview to update). Is this the correct behavior? Or is this a bug?
Start Free Trial