0

I am using XE2 and am trying to incorporate tabs into my Form GUI application and had no idea I would have this much trouble with something so simple..lol.

Anyways...

I have a TTabSet named TTabSet1..

When I try adding a listview to the first tab ONLY it appears on ALL tabs.. Example:

Tab1:

enter image description here

Tab2:

enter image description here

In the IDE:

enter image description here

Should I use another component rather than TTabSet? Also when using TTabSet, inside the IDE I cannot change tabs in order to add components to the other tabs...

I am sorry if you guys have better things to do other than answer my n00b questions lol, but any help is GREATLY appreciated.

Thanks guys.

LU RD
  • 34,438
  • 5
  • 88
  • 296
user1512695
  • 79
  • 3
  • 9

3 Answers3

3

The usage of TTabControl typically involves writing an OnChange event handler to dynamically hide/show (or destroy/create) child controls. To make your life easier, you could create a separate frame for each tab, and simply create and show the relevant frame when the user clicks on a tab, and free the previous one.

TPageControl may be easier to use since you can simply create and populate all the tabs at design time (right-click the page control and select "New Page" to create a new tabsheet). At runtime they are all created when the form is created. The page control manages hiding and showing for you automatically. The downside may be that memory is used for all elements, including the hidden ones, during the whole lifetime of the parent.

Ondrej Kelle
  • 36,941
  • 2
  • 65
  • 128
1

When I try adding a list view to the first tab ONLY it appears on ALL tabs.

In that case it sounds like the component you need is a TPageControl. Each page of a page control has different content.

To add a new page to a TPageControl, right-click the TPageControl object and choose New Page.


The documentation for TTabSet states:

Tab set controls are commonly used to display tabbed pages within a dialog box. TTabSet is provided for backward compatibility. Use TTabControl component in 32-bit Windows applications.

So, even if TTabSet was the right type of control for you, you should be using TTabControl anyway. The choice between TTabControl and TPageControl is resolved as follows:

  1. Do you want each page to show the same controls, albeit with possibly different data inside those controls? If so then use TTabControl.
  2. Do you want each page to show different controls? If so then use TPageControl.
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • ok, well i have tried both.. :/ TPageControl: I could not find anywhere to edit the tabs/pages in properties.. :/ And TTabControl gives me the same issues as in the op.. Sorry again if im being a noob :/ – user1512695 Jul 13 '12 at 09:07
  • @Jens Mühlenhoff I think TPageControl is correct for me, but i cannont seem to find how to edit the "pages"/tabs... as in where to add new ones.. – user1512695 Jul 13 '12 at 09:22
  • @Jens Mühlenhoff It doesn't help me much... This is the properties i can edit in TPageControl, I cannot add new pages/tabs, etc.. http://gyazo.com/bd05bb187df17ee33ad767090a9c35de.png?1342170742 http://gyazo.com/2ce56267e89bf46ba6073718ead4a51a.png?1342171245 Sorry again, i know this may be simple to some but it is driving me absolutely insane! :/ – user1512695 Jul 13 '12 at 09:27
  • 3
    @user1512695: Use right click on the page control and then "New Page". That will create a TTabSheet control (a new tab) on the PageControl that has its own properties like "Caption". – Andreas Hausladen Jul 13 '12 at 09:30
  • Exactly, the TPageControl is only a container for several TTabSheets. – Jens Mühlenhoff Jul 13 '12 at 10:21
  • @user1512695 Hardly. It's far from obvious that you need to right click the control in order to add pages. I trust you are back on track now. – David Heffernan Jul 13 '12 at 10:39
0

You can try TChromeTabs.

TChromeTabs is a comprehensive implementation of Google Chrome's tabs.

Supports:

  • Delphi 6 - Delphi DX10.4 Sydney with High-DPI support
  • FreePascal/Lazarus (Alpha)
Xel Naga
  • 826
  • 11
  • 28