Hi,
I'm using a Data Filter to bind objects to a grid and I need to be able to enter dates for certain columns. If I type the date/time directly into the cell (using the input mask) then it works fine. However, if I click on the drop down button I get the following:
Input string was not in a correct format.(System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Convert.ToDecimal(String value, IFormatProvider provider) at Infragistics.Win.UltraWinMaskedEdit.EditInfo.MinValueForMask(Object minValue, String mask) at Infragistics.Win.UltraWinMaskedEdit.EditInfo.CalculateTrueMinValue() at Infragistics.Win.MonthDropDown.DoDropDown(EmbeddableUIElementBase element) at Infragistics.Win.DateTimeEditor.DoDropDown() at Infragistics.Win.EmbeddableEditorBase.DropDown() at Infragistics.Win.DateTimeEditorDropDownButtonUIElement.OnMouseDown(MouseEventArgs e, Boolean adjustableArea, UIElement& captureMouseForElement) at Infragistics.Win.ControlUIElementBase.ProcessMouseDownHelper(Object sender, MouseEventArgs e) at Infragistics.Win.ControlUIElementBase.ProcessMouseDown(Object sender, MouseEventArgs e) at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e) at Infragistics.Win.UltraControlBase.OnMouseDown(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam))
I've created a small test form to show the problem (just create a form and stick a grid on it):
Imports Infragistics.Win
Public Class DateDropDownTest
Private mValueDt As New DataTable
Private Sub DateDropDownTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mValueDt.Columns.Add("DateCol", GetType(ValueObject))
mValueDt.Rows.Add(New Object() {New ValueObject})
mValueDt.Rows.Add(New Object() {New ValueObject(DateTime.Now)})
UltraGrid1.DataSource = mValueDt
Dim gridCol = UltraGrid1.DisplayLayout.Bands(0).Columns(0)
Dim dateEd = New Infragistics.Win.DateTimeEditor
dateEd.DataFilter = New ValueObjectDataFilter
gridCol.Editor = dateEd
gridCol.Style = UltraWinGrid.ColumnStyle.DateTime
gridCol.MaskInput = "{date} {longtime}"
End Sub
End Class
Public Class ValueObject
Private mDateVal As DateTime
Public Sub New()
mDateVal = DateTime.MinValue
Public Sub New(ByVal val As DateTime)
mDateVal = val
Public Function GetValue() As Object
If mDateVal = DateTime.MinValue Then
Return Nothing
Else
Return mDateVal
End If
End Function
Public Sub SetValue(ByVal val As DateTime)
Public Class ValueObjectDataFilter
Implements Infragistics.Win.IEditorDataFilter
Public Function Convert(ByVal conversionArgs As Infragistics.Win.EditorDataFilterConvertArgs) As Object Implements Infragistics.Win.IEditorDataFilter.Convert
Return Convert(conversionArgs.Value, conversionArgs.Context, conversionArgs.Direction, conversionArgs.Handled)
Public Function Convert(ByVal value As Object, ByVal context As Object, ByVal direction As ConversionDirection, ByRef handled As Boolean) As Object
Dim cell As Infragistics.Win.UltraWinGrid.UltraGridCell
'Check that the object passing through the filter is a grid cell.
If TypeOf context Is Infragistics.Win.UltraWinGrid.UltraGridCell Then
cell = DirectCast(context, Infragistics.Win.UltraWinGrid.UltraGridCell)
Return value
'Action taken depends on the conversion direction.
Select Case direction
Case ConversionDirection.DisplayToEditor
'Do nothing
Case ConversionDirection.EditorToDisplay
If TypeOf cell.Value Is ValueObject Then
handled = True
Return DirectCast(cell.Value, ValueObject).GetValue.ToString
Case ConversionDirection.EditorToOwner
'If the value of the cell is a SamplesViewDataItem then handle the editing of the value.
If value IsNot Nothing AndAlso value IsNot DBNull.Value Then
DirectCast(cell.Value, ValueObject).SetValue(CType(value, DateTime))
Return cell.Value
Case ConversionDirection.OwnerToEditor
'If the value of the cell is a SamplesViewDataItem then handle the display of the value.
Return DirectCast(cell.Value, ValueObject).GetValue
End Select
Any ideas how I can get the drop down to work?
Thanks,
John.
I'm still struggling with this problem.
After reading this http://news.infragistics.com/forums/p/24463/89712.aspx#89712 I've tried changing my regional settings to US with no success.
I've also tried using UltraCalendarCombo as the editor instead of DateTimeEditor but that still gives me an error when I press the drop down button:
System.NullReferenceException: Object reference not set to an instance of an object. at Infragistics.Win.UltraWinSchedule.CalendarCombo.CalendarComboEditor.DoDropDown() at Infragistics.Win.EmbeddableEditorBase.DropDown() at Infragistics.Win.EditorWithTextBaseDropDownButtonUIElement.OnMouseDown(MouseEventArgs e, Boolean adjustableArea, UIElement& captureMouseForElement) at Infragistics.Win.ControlUIElementBase.ProcessMouseDownHelper(Object sender, MouseEventArgs e) at Infragistics.Win.ControlUIElementBase.ProcessMouseDown(Object sender, MouseEventArgs e) at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e) at Infragistics.Win.UltraControlBase.OnMouseDown(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
It doesn't seem to go into the DataFilter code when I press the drop down button, so maybe that's the problem.
Regards,
After several months of being dragged off to do other things I'm back trying to get a Date/Time cell drop down to work with data filters. I've attached a simple VS2008 project that shows the problem.
If you directly type the date/time into the cell then that it works fine but as soon as you click the drop down button to select a date it falls over.
I'm currently using version 8.2.20082.2110.
Hi John,
Can you post a small sample project? You can go to the Options tab when you post to attach a zip file with a project in it.
It's really hard to take a code snippet and make it into a project because there are so many unknowns, like the version of the controls you are using. Also, the forums tend to butcher code formatting as you can see, unless you wrap your code in a "code" tag.