[Solved] Runtime creating controls in new Tab in PageControl lazarus / 31-LCL ---------------------------------------------------------------------- pebe · 2022-02-19 18:42 Hi. I am in the process of creating a program that retrieves information about the contents of a bookmark from an INI file. I have successfully created a new tab: Code: [Select]    actionList.Clear;     conf.ReadSectionValues(section,actionList);     if actionList.Count>0 then     begin       page:=PageControl1.AddTabSheet;       page.Visible:=True;       page.AutoSize:=True;       page.Caption:=actionGroup.Items[actionGroup.ItemIndex];       makePage(page);       PageControl1.ActivePage:=page;       self.DoAutoSize;       closeForm:=false;     end; The procedure that generates its contents looks as follows: Code: [Select]var   actLine:integer;          // actual line in INI section   elType,elParams:String;   // element type (from INI section key) and element parameters (from key value)   elValue:TStringList;   eLabel:TLabel;            // variables for new components   eRadiobutton:TRadioButton;   eCheckBox:TCheckBox;   eInput:TEdit;   i:Integer;                // help variable begin   actLine:=0;   while actLine0 then     begin       elParams:=copy(elType,i+1);       elType:=copy(elType,1,i);     end     else       elParams:='';     // split parameters to array of string     elValue:=TStringList.Create;     elValue.AddDelimitedText(elParams,',',True);     case elType of       'label':         begin           with TLabel.Create(tabSheet) do           begin             Align:=alTop;             Autosize:=true;             Parent:=tabSheet;             Caption:=elValue[0];    // first parameter is label content           end;         end;       'radiobutton':         begin           with TRadioButton.Create(tabSheet) do           begin             // first parameter is Name, but is not used             Align:=alTop;             Parent:=tabSheet;             Caption:=elValue[1];    // secound parameter is Caption             Tag:=actLine;           end;         end;       'checkbox':         begin           with TCheckbox.Create(tabSheet) do           begin             Align:=alTop;             Parent:=tabSheet;             Caption:=elValue[1];             Tag:=actLine;           end;         end;       'input':         begin           with TEdit.Create(tabSheet) do           begin             Align:=alTop;             Parent:=tabSheet;             Tag:=actLine;           end;         end;     end;     elValue.Free;   end; end; The code is not the most beautiful, but it was written on the fly Example INI Section: Code: [Select]label="Krok 1." radiobutton="Found","Pojazd przypisany do OBU" checkbox="TollPass","Znaleziony w TollPass" input=TP-LPN,Rejestracja pojazdu: checkBox="O","Znaleziony w Outlooku" input=OLPN,Rejestracja pojazdu: radiobutton="Not Found',"Brak pojazdu z przypisanym OBU" next=close Unfortunately, after creating the content, nothing shows up for me in the Tab. What I don't know about is what needs to be done to make the contents of the bookmark visible. I send the expected view in the attachment. The form in which the PageControl is located is of modal type, but that doesn't seem to matter much. What I'd like is for the elements that are created in the tab, to be automatically aligned is the top of the tab (hence 'Align:=alTop') and be placed one below the other. The whole window is supposed to adjust in size to the number of components in the tab - this is where I found the TForm.doAutosize procedure, which seems to work. I execute it at the end of creating the tab content. Please Help. ---------------------------------------------------------------------- pebe · 2022-02-19 20:17 OK. I found my mistake. The error was trivial and hid in the logic of dealing with the INI line. I copied one character too many to the element type, which caused the later "Case" to not detect the element. There was one more aspect. I had to set the 'Top' attribute for each element, because without it, the form was created "upside down". It's OK now. I can develop my idea further.