[SOLVED] TTabControl - How to get number of tabs? lazarus / 31-LCL ---------------------------------------------------------------------- Trenatos · 2017-01-31 03:55 I'm working on an IDE, using a SynEdit and TTabControl for the tabs (I'm on OSX El Capitan). I'm loading file content and creating tabs, but I can't figure out how to set the active tab of the TTabControl to the new tab. My idea was to simply add the new tab and set the active tab to the count of the number of tabs. This works once, but that's all. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TabControlFiles.TabIndex := TabControlFiles.RowCount; This doesn't work at all Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TabControlFiles.TabIndex := TabControlFiles.Tabs.Count; I've looked on Google and searched the forum but no luck with this issue. If anyone has an idea I'm open to it. ---------------------------------------------------------------------- balazsszekely · 2017-01-31 05:40 Hi Trenatos, Try this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TabControl1.Tabs.Add('New Tab');  TabControl1.TabIndex := TabControl1.Tabs.Count - 1; It works for me under OSX. ---------------------------------------------------------------------- derek.john.evans · 2017-01-31 05:41 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TabControl1.TabIndex := TabControl1.Tabs.Add('New Tab'); But, I recommend using TPageControl over TTabControl. I believe TTabControl is there for historical reasons. ie: Delphi 1 compatible. The days before Microsoft COM controls. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   PageControl1.ActivePage := PageControl1.AddTabSheet;  PageControl1.ActivePage.Caption := 'New Tab'; ---------------------------------------------------------------------- Thaddy · 2017-01-31 09:53 Anyway for a tab control it is simply: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TabControl1.Tabs.Count;Similar to page control.... Question: do you use code completion or not? Plz do not ask the obvious. Or try better. You are of course always welcome to ask questions but I am always allowed to be a little bit annoyed if the question should have been answered by yourself. ---------------------------------------------------------------------- Trenatos · 2017-01-31 14:00 @GetMem Spot on mate, that -1 did the trick. @Geepster With TPageControl I would have to use one SynEdit per page, this way I only need to use the one and update the content as I go. @Thaddy I do use code completion, without it things would take about a hundred times longer. I searched the web, I looked on the forum, what I did not think about is the fact that the Count starts at 1, but the Tabs are 0 based, which threw off the count. I'm a CFML dev, our arrays are 1 based so this occasionally throws me. Could it/should it have been self-answered, probably, but I did search and I did try and I failed, only then did I ask for help.