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
570
Error in UltraDateTimeEditor when selecting a year via forward button
posted

Hi All !

Szenario:
I' have created a simple application where a user can select a start and stop date/time by two UltraDateTimeEditors. The selectetd start/stop date/time is valid if start (date/time) <= stop (date/time). Otherwise a prompt will be displayed by a MessageBox.

Problem:
When selecting a year at the start (date/time) UltraDateTimeEditor via forward button, the UltraDateTimeEditor's ValueChanged EventHandler goes into an infinity loop.


You can reproduce this behaviour by four steps:

1) Create application with a Form and two UltraDateTimeEditors

2) Create two UltraDateTimeEditors, one for the start time (startDateTimeEditor) and one for the stop time (stopDateTimeEditor)

3) Register on each UltraDateTimeEditors the ValueChanged event and place the source code like this:


        private void startDateTimeEditor_ValueChanged(object sender, EventArgs e) {
            if (sender is UltraDateTimeEditor) {
                int r = this.startDateTimeEditor.DateTime.CompareTo(this.stopDateTimeEditor.DateTime);
                // r = 0    begin == end    ok
                // r = -1   begin <  end    nok
                // r = 1    begin >  end    ok
                if (r == 1)
                    MessageBox.Show("Start time > stop time ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    //Console.Out.WriteLine("Start time > stop time );
            }
        }

        private void stopDateTimeEditor_ValueChanged(object sender, EventArgs e) {
            if (sender is UltraDateTimeEditor) {
                int r = this.stopDateTimeEditor.DateTime.CompareTo(this.startDateTimeEditor.DateTime);
                // r = 0    begin == end    ok
                // r = -1   begin <  end    nok
                // r = 1    begin >  end    ok
                if (r == -1)
                    MessageBox.Show("stop time < start time", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    // Console.Out.WriteLine("stop time < start time ");
            }
        }
        
4) Start the application and select on the start date/time (UltraDateTimeEditor) the year via forward button.

Remark:
When you replace the MessageBox Dialog by a console output, the UltraDateTimeEditor works correct.

Any hint or idea is welcome.
Thanks in advace.

Kind regrads,
Claus