ActivePage and TDateEdit Problem lazarus / 31-LCL ---------------------------------------------------------------------- gkelby · 2015-02-12 10:46 I wonder if anyone has come across this problem.  I have three tab sheets and when the form is initially displayed, the first tab (TabSheet)1 is displayed via the “PageControl1.ActivePage := Tabsheet1” command in the “FormActivate” procedure. I then go to TabSheet3 to enter some data.  That is, the user clicks on the tab for the third Tabsheet, the selected page is displayed, in the “PageControl1Change” event procedure, I use “PageControl1.ActivePage := TabSheet3;” to ensure that TabSheet3 is definitely the active page. One of the fields in TabSheet3 is a TDateEdit field where the user clicks on the calendar icon, selects the date they wish to use and hits the “Enter” key.  Immediately upon doing that, the form reverts to displaying TabSheet1 and all data in TabSheet3 is lost.  This is after setting the ActivePage command to the selected page.  I’ve tried capturing the calendar selection event through DatefieldAcceptDate, DatefieldEditingDone and DatefieldExit.  None of them work. Has anyone encountered this problem?  What is it? And is there a solution? I am using: Lazarus version 1.1.99pre-release, FPC version 2.6.2, SVN version 42829, i386-win32-win32/win64 SQLite3 and Windows 7 Ultimate 64, SQLite V3. Thanks… GK. ---------------------------------------------------------------------- howardpc · 2015-02-12 14:14 Use the form's OnShow event (not OnActivate) to make your pagecontrol display the desired initial page. You don't need to set ActivePage manually - Lazarus does that for you as you navigate between tabs. (Closing the modal calendar window triggers a form.OnActivate event). ---------------------------------------------------------------------- gkelby · 2015-02-13 08:06 Thanks for your assistance but I'm afraid I still need some help with this one.  When the form initially appears what command do I use in the form's OnShow event to set the first displayed tab to TabSheet1 if you suggest I don't use "PageControl1.ActivePage := TabSheet1;"?  And when the user clicks on Tab 3 to display TabSheet3 what do I use to ensure that after the modal calendar is used (the user clicks "Enter") to ensure the displayed page stays on the TabSheet3 displayed page? Thanks for you help... GK ---------------------------------------------------------------------- howardpc · 2015-02-13 10:31 I meant after you've set the ActivePage manually in OnFormShow you should not need to change it again. Provided you don't have an OnActivate event that changes ActivePage, the TabSheet which ActivePage references will not be affected by display and closure of a calendar dialog. So TabSheet3 (or whatever) will regain focus without needing any further code. If it does not, there is some other problem with your code, and it would be best for you to show it in full. ---------------------------------------------------------------------- Bart · 2015-02-13 13:15 Please try with trunk (or wait for 1.4 RC1, should come soon). TDateEdit (actually TEditButton class) was completely rewritten, and there were some fixes made to TCalendar and CalendarPopup. Bart