Hi,
I am running VS2005 and developing a Windows From using VB. I have
attempted to create a simple grid attached to a table adadpter which is
connected to a MSSQL 2005 database; and followed instructions to embed a
calendar control inside a cell as per:
http://msdn.microsoft.com/en-us/library/7tas5c80.aspxWhen I initially load a filtered set of data, all is well and the calendar
control seemingly works perfectly (ie: the calendar controls work as
desired). However, when I load a different subset of data and run across a
date in the format of "1/1/2008" I get an error message in the following code
snippet (code from MS website above):
==========================
==========
===
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)
error here ----> ctl.Value = CType(Me.Value, DateTime)
End Sub
==========================
==========
==========
=
How do I go about trapping this error and correcting the problem? Here is
the error detail:
System.ArgumentOutOfRangeE
xception was unhandled by user code
Message="Specified argument was out of the range of valid values.
Parameter name: rowIndex"
ParamName="rowIndex"
Source="System.Windows.For
ms"
StackTrace:
at System.Windows.Forms.DataG
ridViewCel
l.GetValue
(Int32 rowIndex)
at System.Windows.Forms.DataG
ridViewCel
l.get_Valu
e()
at Diversion_Data_Entry.Calen
darCell.In
itializeEd
itingContr
ol(Int32
rowIndex, Object initialFormattedValue, DataGridViewCellStyle
dataGridViewCellStyle) in C:\Visual Studio 2005\Visual Source Safe
Projects\test\CalendarColu
mn.vb:line
48
at
System.Windows.Forms.DataG
ridView.In
itializeEd
itingContr
olValue(Da
taGridView
CellStyle&
dataGridViewCellStyle, DataGridViewCell dataGridViewCell)
==========================
==========
==========
=======
thank you
suz
Start Free Trial