Can't change DBNavigator's DataSource lazarus / 31-LCL ---------------------------------------------------------------------- Walmir · 2014-08-01 18:56 Hi, I placed a DBNavigator in a main form. It is to be used with many secondary forms and have its DataSource property set at OnActivate and OnShow of these forms, that are opende in various TabSheets. The data controls are in a data module and the data aware controls are in the secondary forms. But, if I open the first form and then open a second form, when a switch back to the first one, the DBNavigator continues locked to the last form opened. Even when I close the last form, the DBNavigator's DataSource don't change when the first form is shown. All data are visible in both forms. ---------------------------------------------------------------------- Walmir · 2014-08-07 12:22 No one can help me with this? ---------------------------------------------------------------------- BigChimp · 2014-08-07 12:33 Posting an example project may help. See my response in your other thread on the forum. ---------------------------------------------------------------------- taazz · 2014-08-07 12:54 Quote from: Walmir on August 01, 2014, 08:56:50 pmHi, I placed a DBNavigator in a main form. It is to be used with many secondary forms and have its DataSource property set at OnActivate and OnShow of these forms, that are opende in various TabSheets. The data controls are in a data module and the data aware controls are in the secondary forms. But, if I open the first form and then open a second form, when a switch back to the first one, the DBNavigator continues locked to the last form opened. Even when I close the last form, the DBNavigator's DataSource don't change when the first form is shown. All data are visible in both forms. Don't use the form's onActivate or onShow use the TPageControl onchange or similar events. It is very possible that the forms events will not be raised when they are parented and not free floating forms. EDIT: Not to mention that you minimize the interdependencies if you use the page control that is already part of the main form and not the secondary form's events and that is only a good thing ---------------------------------------------------------------------- rvk · 2014-08-08 23:11 I had a look at your code. You're doing work (assigning the datasource to the navigator) in FormActivate. If you place a showmessage in the FormActivate of your forms you'll see the FormActivate is never called. That's because your (child)-forms have a parent set. OnActivate and OnDeactivate event handlers are not called if a forms parent property is set. taaz already warned you for this but somehow you completly ignored this. Quote from: taazz on August 07, 2014, 02:54:38 pmDon't use the form's onActivate or onShow use the TPageControl onchange or similar events. It is very possible that the forms events will not be raised when they are parented and not free floating forms. You could perform a simple "hack" by calling the child-forms OnActivate manually in the OnChange event of your TTDINotebook on the mainform. Code: [Select]procedure TfrmMain.tdiAbasChange(Sender: TObject); begin   if tdiAbas.ActivePage is TTDIPage then     if Assigned(TTDIPage(tdiAbas.ActivePage).FormInPage) then       if Assigned(TTDIPage(tdiAbas.ActivePage).FormInPage.OnActivate) then         TTDIPage(tdiAbas.ActivePage).FormInPage.OnActivate(nil); end; (please note that this is not a bug and has nothing to do with the earlier problems with dbnavigator and datasetactions.) ---------------------------------------------------------------------- Walmir · 2014-08-09 16:00 Rvk and Tazz, thank you for your help. Excuse me, I did not see Tazz post. ---------------------------------------------------------------------- Walmir · 2014-08-09 16:59 Quote from: taazz on August 07, 2014, 02:54:38 pmNot to mention that you minimize the interdependencies if you use the page control that is already part of the main form and not the secondary form's events and that is only a good thing What I'm doing here is migrate a Delphi MDI application to a Lazarus TDI one. It seems that it is not so straightforward as I thought.... ---------------------------------------------------------------------- rvk · 2014-08-09 17:07 Quote from: Walmir on August 09, 2014, 06:59:42 pmIt seems that it is not so straightforward as I thought.... Aaah... just a few tweaks here and there    At least you're getting to know Lazarus/FPC really well