Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1878
Strange behaviour when showing a MessageBox from WinDateTimeEditor's ValueChanged Event Handler
posted

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:

  1. Thread 1
  2. Thread 2

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