DateTimePicker.DateTime value is not updated lazarus / 31-LCL ---------------------------------------------------------------------- Vodnik · 2018-03-25 12:32 I have DateTimePicker and Menu controls in my form. Sometimes it happens, that user click to Menu, not having finish entering Time, e.g. previous value was 00:00:00, user entered 1:00:00 and clicked Menu. In that case DateTimePicker.DateTime property is not updated to a new value, and MenuItemClick do processing of an old value (see screenshot). This happens only with Menu, if user click to another control, DateTime value is applied. I would expect there should be a standard procedure that can be called to push update of the control's value or even all values of all controls of a form, but I didn't find one. I tried calling DateTimePicker.Update from MenuItemClick, but it didn't help. What is a workaround for this situation? Windows 7, Lazarus 1.8.0, FPC 3.0.4 ---------------------------------------------------------------------- jamie · 2018-03-25 14:09 Implement the OnEnter event:    Tag := 0; // indicates no change; Implement the OnChange event;   Tag := 1; Implement the OnExit event;  If Tag = 0 then Dosomething about it! ---------------------------------------------------------------------- Vodnik · 2018-03-25 15:55 jamie, I didn't catch... Whether I knew what to do behind "Dosomething", I also could do this in MenuItemClick, isn't it? ---------------------------------------------------------------------- jamie · 2018-03-25 16:14 It means you can handle the fact that the user didn't finish, at which point, I guess you could reset the current value in the picker..?  Show a message box explaining it etc... I suppose you could even store a copy of the current date within the OnEnter event. and then use that to Restore the value if user does not properly exit. There are many options... you need to decide.. I suppose you could also call the OnChange event directly in the OnExit event if you determine that the change didn't take effect.. If Tag = 0 then If Assigned(OnChanged) then OnChanged(Self); at which point you can then take what ever is in there. ---------------------------------------------------------------------- Vodnik · 2018-03-25 16:55 jamie, problem is that DateTimePicker.onExit event do not shoot when user stops entering time from keyboard and clicks a menu item. DateTimePicker control is not loosing the focus while user is clicking menu items. Clicking other controls shoots DateTimePicker.onExit event, but in this case it's own built-in onExit event do the work as well, updating the DateTime property. So your solution do not help in this case. ---------------------------------------------------------------------- Zoran · 2018-03-25 17:10 In MenuItem1Click, first call DateTimePicker1.EditingDone, then do what you want. For example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.MenuItem2Click(Sender: TObject);begin  DateTimePicker1.EditingDone; // makes sure user changes are applied inside DateTimePicker  Label1.Caption := DateToStr(DateTimePicker1.DateTime);end; ---------------------------------------------------------------------- Vodnik · 2018-03-25 17:58 Thanks a lot, Zoran, this did the work!