# DateTimePicker fires DateChanged event when changing month

**URL:** <https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216>\
**Category:** Windows\
**Created:** [March 23, 2021, 3:09pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216 "2021-03-23T15:09:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [March 23, 2021, 3:09pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/1 "2021-03-23T15:09:17Z")

</div>

Target Windows on Xojo 2020r2.1  
Is there a way to stop the datetimepicker from firing the Datechanged event when moving from month to month. I am filling a ListBox when the Date changes but I only want to fill it when the day is selected.  
Edit: Forgot to mention this occurs in the Date graphical view.  
Thanks

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [March 23, 2021, 3:16pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/2 "2021-03-23T15:16:07Z")

</div>

I haven’t tried it yet. Does the SelectedDate also change? If not, the easiest solution is to create a subclass that intercepts that event and tracks the last SelectedDate. It will only re-raise the event to you when the date truly changes.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [March 23, 2021, 3:52pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/3 "2021-03-23T15:52:00Z")

</div>

File a bug report. Walking thru dates and not selecting them should not fire a change or modify the content being edited, before such selection.

---

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [March 23, 2021, 3:53pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/4 "2021-03-23T15:53:10Z")

</div>

I just tried it and the SelectedDate does change when moving from month to month.

---

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [March 23, 2021, 3:54pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/5 "2021-03-23T15:54:51Z")

</div>

I will check in Feedback and see if a bug report has been filed.  
Thanks Rick

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [March 23, 2021, 4:02pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/6 "2021-03-23T16:02:05Z")

</div>

That’s a bummer.

---

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [March 23, 2021, 5:25pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/7 "2021-03-23T17:25:09Z")

</div>

Feedback case filed case 64136

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [March 24, 2021, 2:20pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/8 "2021-03-24T14:20:50Z")

</div>

This renders the control useless, people will change some dates in some forms without noticing causing data damages everywhere.

---

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [March 24, 2021, 3:01pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/9 "2021-03-24T15:01:53Z")

</div>

To make matters worse, The datechanged event fires twice every time.

---

<div class="post-metadata">

**Author:** ![DerkJ](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@DerkJ](https://forum.xojo.com/u/DerkJ)\
**Post date:** [March 24, 2021, 3:04pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/10 "2021-03-24T15:04:31Z")

</div>

I dont see that behaviour here when using the month changer (left \< or right \>).  
Duplicate events happen if you click a day in the list, that’s clearly happening here too.  
In the dateChanged event:

`System.DebugLog CurrentMethodName + ", "+value.ToString`

I get only 1 call even when i loose the focus of the control, i won’t get another event raised.

I do note that there is no GotFocus and LostFocus events that would be rather useful in this control.

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [March 24, 2021, 3:06pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/11 "2021-03-24T15:06:45Z")

</div>

Did you provide a sample privately? If not, please provide one (public or private), that will speed the review process.

---

<div class="post-metadata">

**Author:** ![Jürg\_Otter](https://forum.xojo.com/user_avatar/forum.xojo.com/j%C3%BCrg_otter/32/584_2.png) [@Jürg\_Otter](https://forum.xojo.com/u/J%C3%BCrg_Otter)\
**Post date:** [March 24, 2021, 3:19pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/12 "2021-03-24T15:19:47Z")

</div>

> [@Kem\_Tekinay](#):
>
> That’s a bummer.

No, just a new Control in it’s first Xojo Version. 😉

It just confirms what we’ve seen with so many other new features. It takes a couple of Xojo versions until they’re ready.

> [@DerkJ](#):
>
> I do note that there is no GotFocus and LostFocus events that would be rather useful in this control.

And without being able to set it’s Font/Size, it just doesn’t fit properly in our UI 😉  
That’s \<[https://xojo.com/issue/62860](https://xojo.com/issue/62860)\>.

At least… Xojo should be aware of all that. We’ve all provided Feedback. It’s up to them to deliver - until then I’m just having to ignore that Control. I’d love to be surprised with a full-featured and useable Control in an upcoming release.

---

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [March 24, 2021, 3:48pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/13 "2021-03-24T15:48:33Z")

</div>

@derkj It is clearly happening in my app. I just added your debug log code to the dateChanged event and it logged it when I moved to a previous month, without clicking anything else. No other code is in the datechanged event. I tried it with the control on a window and in container. Xojo 2020r2.1 on Windows.  
For the duplicate event firing, I call a timer which calls my method. The timer stops the event from firing twice.

---

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [March 24, 2021, 3:50pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/14 "2021-03-24T15:50:06Z")

</div>

@AlbertoD I did not not provide a sample project but I will go and add one now.  
Thanks

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [March 24, 2021, 4:23pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/15 "2021-03-24T16:23:48Z")

</div>

Consider building that into a subclass.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [March 24, 2021, 5:28pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/16 "2021-03-24T17:28:35Z")

</div>

When Gary reported it, I’ve saw exactly what he reported In 2020r2.1 in a simple test.

---

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [March 24, 2021, 10:07pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/17 "2021-03-24T22:07:32Z")

</div>

@Kem_Tekinay I subclassed it but not sure what to do next. Any help would be appreciated.  
Thanks

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [March 24, 2021, 10:41pm UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/18 "2021-03-24T22:41:40Z")

</div>

There’s not enough exposed properties and events to detect the involved states to properly workaround the bugs. The control needs Xojo intervention urgently.

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [March 25, 2021, 4:34am UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/19 "2021-03-25T04:34:02Z")

</div>

In the subclass, implement the DateChanged event and have it start a Timer built into the subclass, RunMode = Single. That Timer will Raise your own DateChanged event to the subclasses, so as far as your subclasses are concerned, the event only fires once.

---

<div class="post-metadata">

**Author:** ![Sunil\_Abraham](https://forum.xojo.com/user_avatar/forum.xojo.com/sunil_abraham/32/437_2.png) [@Sunil\_Abraham](https://forum.xojo.com/u/Sunil_Abraham)\
**Post date:** [March 25, 2021, 5:29am UTC](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216/20 "2021-03-25T05:29:25Z")

</div>

The same issue is there with Einhugur date control. When i contacted he said he don’t have any solution for it. So may be its an issue from the windows date control itself.

[Next page](https://forum.xojo.com/t/datetimepicker-fires-datechanged-event-when-changing-month/62216.md?page=2)
