When setting ActivePage property for the TPageControl control, from code, the OnChanging and OnChange events are not triggered. By design, those events are only fired when a user clicks on a tab to activate the page (TabSheet) on a TPageControl.
One way to "fix" this behavior is to use the "protected hack" technique. By exposing the protected TPageControl's CanChange and Change methods you will be able to set the ActivePage from code while making sure OnChange and OnChanging fired.
~~~~~~~~~~~~~~~~~~~~~~~~~
type
THackPageControl = Class(TPageControl) ;
procedure SetAsActivePage(tabSheet : TTabSheet) ;
begin
if tabSheet.PageControl.ActivePage <> tabSheet then
begin
If THackPageControl(tabSheet.PageControl).CanChange then
begin
tabSheet.PageControl.ActivePage := tabSheet;
THackPageControl(tabSheet.PageControl).Change;
end
else Abort;
end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Delphi tips navigator:
» Moving the focus to the next Delphi edit control when MaxLength characters have been reached
« Fixing the "Transaction ... an object is in a zombie state"

