Many events with controls that involves interaction with the USER should only fire (trigger) when the
user CLICKS on a tab, for example.
Because you do this in your code, you should be calling the event directly if that is what you
wish to happen..
So when changing a state in a control via code and that same event can also get called when the
user interacts with the control, should be isolated.
Create a stand alone Procedure that will need to be called if your code or the USER changes the tab
index.
-- For USER actions (Click) ___
OnChange(....)
Begin
Call_Basic_PRocedure;
// do other code that reflects user ACTION only here..
End;
-- For your code to make changes ---
PageControl.ActuvePageIndex := 2;
Call_basic_Procedure...
---------
If you truly do need all of the code inside of the Onchange event to take place for both events, USER or your
code, then you can simply directly call the event from your code.
Just call the Event directly..
Like I said early, any events that get triggered from USER interactions of the control should not get triggered
when using CODE to directly change the same properties. In this case your code should be doing it instead.
There are a few controls in the LIBS that call Onchange from both direct code or user interaction when they
really shouldn't be doing that, it causes confusion in code when you need to decide how the code got executed.