Datagridview Calendar Column DBNull Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've inserted a Calendar Column in my Datagridview. It works fine except for
2 issues:

1. The date appears in the AddNew Row...I would rather it only activated
when a new row is added (or read of course)

2. If the user clicks on the Calendar Column first ...in the AddNew row...I
get a DBNull error...instead of a new row being added. Here's the affected
code:

Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer,
ByVal initialFormattedValue As Object, ByVal dataGridViewCellStyle As
DataGridViewCellStyle)
' Set the value of the editing control to the current cell value.
MyBase.InitializeEditingControl(rowIndex, initialFormattedValue,
dataGridViewCellStyle)
Dim ctl As CalendarEditingControl =
TryCast(DataGridView.EditingControl, CalendarEditingControl)
ctl.Value = CDate(Me.Value)
End Sub

Any help would be appreciated.

Thanks Arne
 
Back
Top