Author Topic: [Solved]TPageControl  (Read 1027 times)


  • Sr. Member
  • ****
  • Posts: 388
« on: February 14, 2018, 12:15:02 am »

 i have many TPageControl in my project.
 i write some codes in the  "PageChange" event.
 in body of my project , i use this code :
 PageControl1.activepageindex := 2
 with this code , i chage page index and also run codes of "PageChange" event.
 when i install lazarus 1.8 (that i wish didn't do this)
 i just open my project and run it .
 when i use :
 PageControl1.activepageindex := 2

only page of pagecontrol change and code of "PageChange" event doesn't run.


please run this project in Lazarus1.6  and Lazarus 1.8 and see this different

and guide me.

Thank you
« Last Edit: February 16, 2018, 11:07:17 am by majid.ebru »


  • Hero Member
  • *****
  • Posts: 1195
Re: TPageControl
« Reply #1 on: February 14, 2018, 12:38:13 am »
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

-- For USER actions (Click) ___
      // do other code that reflects user ACTION only here..

-- For your code to make changes ---
   PageControl.ActuvePageIndex := 2;

 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.


  • Hero Member
  • *****
  • Posts: 5347
Re: TPageControl
« Reply #2 on: February 14, 2018, 12:55:24 am »
This has been removed in version 1.8 for Delphi compatibility. See

When you read this you will learn that there is a simple fix: set the PageControl Option nboDoChangeOnSetIndex, and you will have the old behavior back.

You might want to read also the rest of the 1.8-release-notes to learn about other code-breaking changes.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10


  • Sr. Member
  • ****
  • Posts: 388
Re: TPageControl
« Reply #3 on: February 14, 2018, 03:54:58 am »

thank you

it's work
« Last Edit: February 16, 2018, 11:07:02 am by majid.ebru »