0

I need to react at TDateTimePicker.OnChangeEvent on date change. Display dialogs like "Unsaved changes will be lost" with buttons OK, Cancel. If the user press Cancel button I want to reset back the original date.

Unfortunatelly I can't change the date from that event. Change is ignored.

More detailed description:

  1. User change the date in DateTimePicker (by keyboard) or Opens the calendar and pick a date
  2. OnChange event is fired (calendar maybe still open)
  3. I display the MessageDialog and if user press "Cancel" I want to restore date. Eg. close the calendar and restore date.
Vlada
  • 559
  • 2
  • 11
  • 27
  • When the user cancels, the date picker on change event won't fire. So, I can't understand the problem. I think you need to make it a little clearer. – David Heffernan Mar 14 '13 at 10:03
  • 4
    See [`"Correct the value on datetimepicker when user selects a date"`](http://stackoverflow.com/q/2238221/576719). Restore the value in the `OnCloseUp` event. – LU RD Mar 14 '13 at 10:03
  • On the other hand, the `OnCloseUp` event is executed long before your confirmation dialog is done. So better handle this in another way. If the user cancels the edit, just set the datetimepicker value to the restored value. – LU RD Mar 14 '13 at 10:34

1 Answers1

0

It is partially solved by user LU RD - see comments "Restore the value in the OnCloseUp event". It works for choosing date from a calendar.

If user change date directly in edit using keyboard it can be changed directly in onChangeEvent.

So combination of setting original (or any other date) in onCloseUp and onChange event is enough.

Vlada
  • 559
  • 2
  • 11
  • 27