Sign in Join
Wiki copytemporary

TTabControl

English · Français · Русский · 中文(中国)

TTabControl is a descendant of TWinControl and can be found on the Common Controls tab of the Component Palette.

It is a tabbed container component which looks identical to a TPageControl. However, there is a fundamental difference because the control always shows the same page whichever tab is selected. In fact, it containts only a single page. The idea behind this concept is illustrated best by an editor or viewer for text files: When the TabControl contains a TMemo then the individual tabs refer to the files loaded into the memo; whenever the active tab changes another file is loaded into the (same) memo.

Since the TTabControl contains only a single page there is no Pages property as for the TPageControl. The individual tab captions are stored in a TStrings property named Tabs.

The currently selected tab can be identified by means of its index, TabIndex.

Navigating between tabs

The user can navigate between tabs by clicking on the tab to be used. By code, the same can be achieved by assigning the index of the new tab to the TabIndex property of the TTabControl.

Whenever another tab is displayed two events are fired:

Adding tabs

pascal
procedure TForm1.AddTabBtnClick(Sender: TObject);
begin
  TabControl1.Tabs.Add('abc');
end;

Deleting tabs

pascal
procedure TForm1.DeleteTabBtn(Sender: TObject);
begin
  if TabControl1.TabIndex > -1 then
    TabControl1.Tabs.Delete(TabControl1.tabIndex);
end;

Similar controls

See also


From the Free Pascal wiki, page "TTabControl", as it stood on 2021-02-06 after a change by Wp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.