We continue to have problems with using a GridViewDateTimeColumn with DateTimeOffset. I *thought* we had this working months ago, but revisited a feature that we have not used for many months and we cannot get it to work. Don't know if it is due to the version of the controls we are using? Or something we have done.
We continue to either get "Converter can't convert" or other types of formatting errors. To help demonstrate this problem, we did a very simple sample. Just try to drop down one of the calendar drop downs and the error occurs.
Here is the code:
Please let us know what we need to do to get this to work.
THANKS!
We continue to either get "Converter can't convert" or other types of formatting errors. To help demonstrate this problem, we did a very simple sample. Just try to drop down one of the calendar drop downs and the error occurs.
Here is the code:
Imports System.ComponentModel
Imports Telerik.WinControls.UI
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TimeCardGrid.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
TimeCardBindingSource.DataSource = TimeCards.Retrieve()
End Sub
End Class
Public Class TimeCard
Public Property StartTime As DateTimeOffset?
Public Property endTime As DateTimeOffset?
End Class
Public Class TimeCards
Inherits BindingList(Of TimeCard)
Public Shared Function Retrieve() As TimeCards
Dim timeCardList As New TimeCards From
{New TimeCard With {.StartTime = New DateTimeOffset(2011, 12, 8, 9, 45, 30, New TimeSpan(-8, 0, 0)),
.endTime = New DateTimeOffset(2011, 12, 9, 11, 45, 30, New TimeSpan(-8, 0, 0))},
New TimeCard With {.StartTime = New DateTimeOffset(2011, 12, 11, 9, 45, 30, New TimeSpan(-8, 0, 0)),
.endTime = New DateTimeOffset(2011, 12, 12, 11, 45, 30, New TimeSpan(-8, 0, 0))}}
Return timeCardList
End Function
End Class
<
Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated
()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<
System.Diagnostics.DebuggerNonUserCode
()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<
System.Diagnostics.DebuggerStepThrough
()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim GridViewDateTimeColumn1 As Telerik.WinControls.UI.GridViewDateTimeColumn = New Telerik.WinControls.UI.GridViewDateTimeColumn()
Dim GridViewDateTimeColumn2 As Telerik.WinControls.UI.GridViewDateTimeColumn = New Telerik.WinControls.UI.GridViewDateTimeColumn()
Me.TimeCardBindingSource = New System.Windows.Forms.BindingSource(Me.components)
Me.TimeCardGrid = New Telerik.WinControls.UI.RadGridView()
CType(Me.TimeCardBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.TimeCardGrid, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'TimeCardBindingSource
'
Me.TimeCardBindingSource.DataSource = GetType(WindowsApplication9.TimeCard)
'
'TimeCardGrid
'
Me.TimeCardGrid.Location = New System.Drawing.Point(12, 12)
'
'TimeCardGrid
'
Me.TimeCardGrid.MasterTemplate.AllowAddNewRow = False
Me.TimeCardGrid.MasterTemplate.AllowColumnChooser = False
Me.TimeCardGrid.MasterTemplate.AllowColumnReorder = False
Me.TimeCardGrid.MasterTemplate.AllowDeleteRow = False
Me.TimeCardGrid.MasterTemplate.AllowDragToGroup = False
Me.TimeCardGrid.MasterTemplate.AutoGenerateColumns = False
GridViewDateTimeColumn1.DataType = GetType(System.Nullable(Of System.DateTimeOffset))
GridViewDateTimeColumn1.FieldName = "StartTime"
GridViewDateTimeColumn1.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
GridViewDateTimeColumn1.FormatString = "{0:d}"
GridViewDateTimeColumn1.HeaderText = "StartTime"
GridViewDateTimeColumn1.Name = "StartTime"
GridViewDateTimeColumn2.DataType = GetType(System.Nullable(Of System.DateTimeOffset))
GridViewDateTimeColumn2.FieldName = "EndTime"
GridViewDateTimeColumn2.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
GridViewDateTimeColumn2.FormatString = "{0:d}"
GridViewDateTimeColumn2.HeaderText = "EndTime"
GridViewDateTimeColumn2.Name = "EndTime"
Me.TimeCardGrid.MasterTemplate.Columns.AddRange(New Telerik.WinControls.UI.GridViewDataColumn() {GridViewDateTimeColumn1, GridViewDateTimeColumn2})
Me.TimeCardGrid.MasterTemplate.DataSource = Me.TimeCardBindingSource
Me.TimeCardGrid.MasterTemplate.ShowFilteringRow = False
Me.TimeCardGrid.MasterTemplate.ShowRowHeaderColumn = False
Me.TimeCardGrid.Name = "TimeCardGrid"
Me.TimeCardGrid.ShowGroupPanel = False
Me.TimeCardGrid.Size = New System.Drawing.Size(315, 235)
Me.TimeCardGrid.TabIndex = 2
Me.TimeCardGrid.Text = "RadGridView1"
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(347, 263)
Me.Controls.Add(Me.TimeCardGrid)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.TimeCardBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.TimeCardGrid, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents TimeCardBindingSource As System.Windows.Forms.BindingSource
Friend WithEvents TimeCardGrid As Telerik.WinControls.UI.RadGridView
End Class
Please let us know what we need to do to get this to work.
THANKS!