Advertisement

05.06.2008 at 07:44AM PDT, ID: 23379611
[x]
Attachment Details

Assistance with Windows Forms and calendar control embedded inside a grid

Asked by suz7777 in Visual Studio, .NET, Microsoft Visual Basic.Net

Tags: , ,

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.aspx

When 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(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 = _
            CType(DataGridView.EditingControl, 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.ArgumentOutOfRangeException was unhandled by user code
  Message="Specified argument was out of the range of valid values.
Parameter name: rowIndex"
  ParamName="rowIndex"
  Source="System.Windows.Forms"
  StackTrace:
       at System.Windows.Forms.DataGridViewCell.GetValue(Int32 rowIndex)
       at System.Windows.Forms.DataGridViewCell.get_Value()
       at Diversion_Data_Entry.CalendarCell.InitializeEditingControl(Int32
rowIndex, Object initialFormattedValue, DataGridViewCellStyle
dataGridViewCellStyle) in C:\Visual Studio 2005\Visual Source Safe
Projects\test\CalendarColumn.vb:line 48
       at
System.Windows.Forms.DataGridView.InitializeEditingControlValue(DataGridViewCellStyle& dataGridViewCellStyle, DataGridViewCell dataGridViewCell)
=====================================================

thank you
suz
Start Free Trial
 
Loading Advertisement...
 
[+][-]05.07.2008 at 02:06AM PDT, ID: 21514412

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio, .NET, Microsoft Visual Basic.Net
Tags: VB.Net, Windows Forms, System.ArgumentOutOfRangeException was unhandled by user code
Sign Up Now!
Solution Provided By: vbturbo
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628