Hi,
I've created a simple dialog that shows a single WinDateTimeEditor. In the handler function for ValueChanged event I'm testing if the date is before current date and if not I'm showing a message box to the user. This works fine so far except when using the scroll button to move one month back. In that case when moving before current date the message box gets displayed and when closing it the WinDateTimeEditor continues moving back in time until I click somewhere else in this dialog. Here is the implementation of the handler function.
private void OnSmpEndDatePickerValueChanged(object sender, EventArgs e) { if (dteSmpEndDate.DateTime < DateTime.Now) MessageBox.Show("Selected day must not before current date!"); }
If I'm using MessageBoxManager from Infragistics to display the message box after closing it I get following exception:
System.InvalidOperationException: Operation is not valid due to the current state of the object. at System.Windows.Forms.MonthCalendar.WndProc(Message& m) at Infragistics.Win.MonthDropDownWithUIPermissions.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I'm using NetAdvantage v15.1
When searching this forum if this is maybe a known problem I found two rather old threads:
It seems that this problem exists for a while and has not been fixed yet or it appeared again recently?
I found a workaround that works for me by using AfterCloseup and AfterExitMode events instead. Just wanted let you know :-)
Kind regards,
Wolfgang
Hello Wolfgang,
Thank you for posting in our forum.
This is a bug with the .NET MonthCalendar and not the DateTimeEditor. This can be reproduced without using any Infragistics controls by simply placing a .NET MonthCalendar on the form and showing a MessageBox in the DateChanged event handler.
Thank you for sharing with us your workaround.
Hello Milko,
thanks for your instant reply. I'm using the WinDateTimeEditor from Infragistics, I've verified that to make sure that I didn't use the .NET control but it is definitely the control from Infragistics. Is this control inherited from .NET MonthCalendar that it shows same behaviour?