Datagridview Calendar Column DBNull Error

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top