Recent

Author Topic: TCDPageControl's TabSheet Order  (Read 5727 times)

NelsonN

  • Jr. Member
  • **
  • Posts: 69
    • Beam Me Up!
TCDPageControl's TabSheet Order
« on: July 25, 2012, 01:38:04 pm »
Hi,

I am using the Custom Drawn Controls, specifically the TCDPageControl. The problem I am facing is that there is no PageIndex to control the order of the tabs on the CDPageControl. I need to use TCDPageControl because I can change its colors.

The order of my Tabs in one of my CDPageControl's should be:

File Settings | Page Settings | Affiliate Settings

I think that the order changes as I select the tabsheets in the UI to work on them.

Can someone point me in the right direction to help me set the order in code, so that they are always in the order I specify?
Lazarus trunk / FPC 3.0.4 / 32-bit and 64-bit with Windows 10.

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: TCDPageControl's TabSheet Order
« Reply #1 on: July 25, 2012, 03:55:35 pm »
I don't use CustomDrawn, so not sure if this is the correct way, but this appears to work

Code: [Select]
procedure MoveTab(t:TCDPageControl;from,too:integer);
begin
  t.Tabs.Move(from,too);
  if t.PageIndex=from then t.pageindex := too
  else if t.pageindex=too then t.pageindex := from;
  t.invalidate;
end;       

And then if you want say TabPosition 1 moving to TabPostion 0,
Code: [Select]
  MoveTab(cdpagecontrol1,1,0);

edit: oops, missed a bit.
« Last Edit: July 25, 2012, 04:12:29 pm by KpjComp »

NelsonN

  • Jr. Member
  • **
  • Posts: 69
    • Beam Me Up!
Re: TCDPageControl's TabSheet Order
« Reply #2 on: July 25, 2012, 05:01:43 pm »
My tabsheets order are:

Affiliate Settings | Page Settings | File Settings

After these commands:

Code: [Select]
MoveTab(CDPageControl1,2,0); { Tab Position 2, to Position 1 }
MoveTab(CDPageControl1,1,2); { Tab Position 1, to Position 2 }

They are rearranged as:

File Settings | Page Settings | Affiliate Settings

A bit tricky but it works.

Thanks for the help, it is appreciated!
Lazarus trunk / FPC 3.0.4 / 32-bit and 64-bit with Windows 10.

NelsonN

  • Jr. Member
  • **
  • Posts: 69
    • Beam Me Up!
Re: TCDPageControl's TabSheet Order
« Reply #3 on: July 30, 2012, 10:53:25 pm »
For those who might be as dense as I was with these TabSheets, here is another helpful tip.

I was guessing at the tabs I needed to move, if you want to find the Tab you want to move to a certain position use Tabs.IndexOf to find that tab.

Code: [Select]
MoveTab(CDPageControl1,CDPageControl1.Tabs.IndexOf('File Settings'),0); { Move to Position 0 }
MoveTab(CDPageControl1,CDPageControl1.Tabs.IndexOf('Page Settings'),1); { Move to Position 1 }

Tabs.IndexOf uses the Caption of the TabSheet. I have three Tabs so I only need to move two of them to be sure.

No more guessing.  :D
Lazarus trunk / FPC 3.0.4 / 32-bit and 64-bit with Windows 10.

Knipfty

  • Full Member
  • ***
  • Posts: 232
Re: TCDPageControl's TabSheet Order
« Reply #4 on: July 30, 2012, 11:30:42 pm »
NelsonN,

Have you or anyone else able to move tab by dragging them?

Thanks

Knipfty
64-bit Lazarus 2.2.0 FPC 3.2.2, 64-bit Win 11

NelsonN

  • Jr. Member
  • **
  • Posts: 69
    • Beam Me Up!
Re: TCDPageControl's TabSheet Order
« Reply #5 on: July 31, 2012, 03:47:50 am »
No, I have never tried it, and I don't have a need for it, at the moment, so can't tell you anything about it.
Lazarus trunk / FPC 3.0.4 / 32-bit and 64-bit with Windows 10.

 

TinyPortal © 2005-2018