2

I am running Lazarus 0.9.30.2.

I have a TForm on which there is a TPageControl. Within the TPageControl there is a series of TTabSheets. At runtime the order of the TTabSheets differs from design time (see picture).

enter image description here

The order in design time is what I want to see at runtime, at least for the very first time the form is displayed. Why does the order change at run time and is there a way to control this?

TLama
  • 75,147
  • 17
  • 214
  • 392
user1174918
  • 525
  • 6
  • 22
  • 3
    I've added Delphi tag since the same you can see also in Delphi. Seems more like the Windows tab control behavior, something like when the control is being created and the [`TCS_MULTILINE`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb760549%28v=vs.85%29.aspx#TCS_MULTILINE) style is set, the tabs order is lost. – TLama Mar 08 '12 at 12:43
  • 1
    I have seen some Really Weird Tab control issues, but this one is actually pretty understandable, and seems pretty workable. Have you tried changing the tab style to show buttons? Then it might not reorder them. – Warren P Mar 08 '12 at 14:16

1 Answers1

4

@TLama is correct that this is related to way the Windows tab control behaves when in multi-line view. The behaviour you are observing is related to the way selection is handled for multi-line tabs. When you select a tab it is always shown in the bottom row because the visual cue to indicate which tab is selected can only really work for tabs in the bottom row.

Given that constraint the control simply has to rearrange rows of tabs as you modify the selected tab. It's astoundingly confusing for the user. Good UI design never has UI elements changing position like this.

Clearly what is happening here is that the rearrangement is happening at runtime when the form is first shown and for whatever reason this is resulting in a different arrangement from the design time arrangement. Given that the user can arrange the rows in any order just by selecting them I'm not sure you should worry about what order the rows appear in.

If you are dead set on forcing a particular arrangement when the form first shows you can add code like this to a OnCreate handler for the form:

PageControl1.ActivePage := TabSheet9;
PageControl1.ActivePage := TabSheet5;
PageControl1.ActivePage := TabSheet1;

Best practise for UI design is to avoid multi-line tab controls and I urge you to attempt to re-design your UI that way.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • I have 30 TabSheets so the only options are (i) live with it (ii) to not use multi line style set and as a result use the default scrolling behaviour of the TPageControl. – user1174918 Mar 08 '12 at 12:55
  • 2
    @user1174918 I've added some code to explain how you can at least control the order in which the rows of tabs appear when your form first shows. But I'd look for alternative UI. 30 tabs seems too many in my view. – David Heffernan Mar 08 '12 at 12:58
  • 2
    @user1174918, I guess by "re-design" David meant more work than just setting MultiLine to False. :-) I.e. group the contents somewhat differently, use nested tabcontrols (not **that** user-friendly either), or what-not. – Uli Gerhardt Mar 08 '12 at 14:20