468,272 Members | 2,036 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

Datagridview Calendar Column DBNull Error

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
Feb 17 '07 #1
0 1629

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Laz | last post: by
4 posts views Thread by ReneMarxis | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.